ActionView::Template::Error (no such file to load -- eco
How do I get Rails 3.1 to package my Eco templates?
Add the following line to your Gemfile:
gem 'eco'
Run bundle install and Sprockets (a.k.a. the asset pipeline) is now ready to compile .eco files in app/assets/javascripts to JavaScript.
How do I find and render my Eco templates in my CoffeeScript?
Let's assume you want your embedded template to live in:
app/assets/javascripts/todos/views
If you think you can name your template todo.eco or even todo.js.eco, you're wrong. (Todos is an archetypical JavaScript framework demo app.) Although the template compiles down to a JavaScript function, at the time of this writing, the JavaScript compiled from todo.js.eco will produce a runtime error. Apparently, a JavaScript templating system is required. The easiest solution is to use JST, which Sprockets provides by default. (jQuery Templates are another option, via the sprockets-jquery-tmpl gem.)
Thus,
app/assets/javascripts/todos/views/todo.jst.eco
can be rendered in your CoffeeScript using:
JST['todos/views/todo']()
For a full working example of Eco templates with Rails and Spine, check out Alex MacCaw's infinite scrolling screencast and source.
Update (12/14/2011): Slides from my presentation on Eco at URUG are now online: http://backbonecoffeescript.com/eco-coffeescript-templates