toffee
toffee copied to clipboard
Any plans for a ruby gem that can be used with Rails asset pipeline
First of all, great job on this templating engine. Really easy to use & understand syntax.
Are there any plans for a ruby gem anytime soon that be used with Rails asset pipeline? Thanks
This is very interesting to me. Although: I have never used ruby before, other than just poking around back when RoR first started getting popular.
So I don't know what this would require. When you refer to the asset pipeline, are you talking about server-side rendering of templates, or just getting toffee templates onto the browser (for rendering client side) in a Rails project?
Toffee relies on CoffeeScript itself for evaluation the #{} regions and of course anything inside of coffeescript region: {# #}. So getting this working server-side in rails requires running JavaScript. Is there a way to execute JavaScript in ruby?
Btw, an alternative is a new templating language just like Toffee, except Ruby instead of CoffeeScript inside the appropriate regions. People might like that, too.
Apart from the JS templating, eco implements this for the server side as well. So, in development, I write eco templates show.jst.eco and save. When I refresh the page, the browser makes a call to the server, which ends up compiling the eco template to JS using coffescript and the eco preprocessor.
Its similar to how the coffeescript & sass files are preprocessed in the Rails asset pipeline.
I do not have the time right now to develop this, but their are quite a few examples of Rails asset-pipeline preprocessors out there.
I just took a look at eco's ruby implemention: https://github.com/sstephenson/ruby-eco ... it appears he uses a library called ExecJS to let a ruby user compile the templates via the shell and then eval them. This kind of thing should be doable with Toffee (since it also can compile templates to JS at the command line into a single package), although I prob won't get a chance to mess with this in the next couple weeks. I suspect it's easy for someone who knows what they're doing in ruby, if there are any volunteers...
-cc
+1 for Ruby on rails integration into asset pipeline