Did you compile it with --fast?
EJS Views Helpers With Backbone-Rails
Backbone-Rails is a useful gem for setting up Backbone.js in your Rails 3.1 app by providing all the necessary javascript files & dependencies (easy future upgrades with bundler), as well as some generators to setup your MVC directory structure. It uses EJS (Embedded JavaScript, part of Underscore.js I believe) as it's default javascript templating language and installs the ruby-ejs gem as a dependency.
Now when you try to create some templates, there are two gotchas to watch out for. The first is that ruby-ejs doesn't include the actual EJS javascript file, which is necessary if you want to use EJS Views helpers in your templates. So, for example, if you wanted to use textfield_tag in edit.jst.ejs, their wiki would have you write:
<%= text_field_tag("name", name) %>
Which will give you an error. The solution is to download EJS from the website & throw it in /vendor/assets/javascripts. The second gotcha is that you have to fully-qualify the helper functions, at least in the generator-produced structure that I'm aware of, so the proper code is:
<%= EJS.Helpers.prototype.text_field_tag("name", name) %>
So!
- Download the EJS Javascript files to /vendor/assets/javascripts
- Fully-qualify the helper functions as EJS.Helpers.prototype.whatever_tag
Or you could use Mustache / Handlebars (which I think I'll end up doing).







Comments
Thank you for your article!
vivienne westwood shoes are the newest popular shoes. 100% premium vivienne westwood sale . Special design vivienne westwood outlet will give you different feeling.Right now there are so many vivienne westwood online anything for you to choose.Don't hesitant to pick up your favorite Cheap Air Max pairs to buy michael kors outlet .Make a profit but buying more than one pair of cheap michael kors handbags outletand be happy about it.