Skip to content

add Bldr::Template.render to easily render templates outside of views #35

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

ajsharp
Copy link
Owner

@ajsharp ajsharp commented Nov 24, 2013

A common use case is rendering a model's json when "bootstrapping" an html page so javascript classes / views can make use of the model data:

<div class="person">
</div>

<script>
App.person = new App.Person(<%= raw(Bldr::Template.new('appointments/show', locals: {appointment: @appointment})) %>)

App.personView = new App.PersonView(model: App.person, el: '.person')
</script>

@@ -1,6 +1,17 @@
require 'spec_helper'

module Bldr
describe '.template' do
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would expect you to be testing .template here, but you're actually testing .render. So maybe describe Template, '.render' is more clear?

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch. Typo :)

  • alex

On Nov 25, 2013, at 5:27 PM, Adam LaFave [email protected] wrote:

In spec/functional/tilt_template_spec.rb:

@@ -1,6 +1,17 @@
require 'spec_helper'

module Bldr

  • describe '.template' do
    I would expect you to be testing .template here, but you're actually testing .render. So maybe describe Template, '.render' is more clear?


Reply to this email directly or view it on GitHub.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants