I understand sharing templates between Ruby and JavaScript can be done in Rails (as seen in Railscast #295). There is something about Mustache that I don't like, though.
I would love to accomplish this using eco (Embedded CoffeeScript).
I created the eco template handler in config/initializers/eco_template_handler.rb
:
module EcoTemplateHandler
def self.call(template)
Eco.render(template.source.inspect, template.locals)
end
end
ActionView::Template.register_template_handler(:eco, EcoTemplateHandler)
Which will allow me to render .eco files from within the server templates (i.e., <%= render 'form' %>
will render _form.html.eco). However, this is only half of the equation.
According to some people (and more), you need to use JST for eco to work in JavaScript templates. I'm not too familiar with JST.
Is this possible? Has anyone been able to accomplish this?