I am looking for a template solution that can work on both server side (like ERB) and client side (like EJS) so I don't have to write the views twice for use in, say, both Rails and Backbone.
The first that comes to mind is Mustache. Any others?
Anyone doing this successfully ?
EDIT
I keep a compilation Here.
JavaScript is an important client-side scripting language and widely used in dynamic websites. The script can be embedded within the HTML or stored in an external file.
Templating language is basically string interpolation which builds the presentational layer at load time. Client side code is developed separately and has to “pick up” the target elements after it is loaded.
Another approach is to use client-side templating. Client-side templating libraries allow you to create HTML with placeholders for your dynamic data. These libraries allow you to pass data to a template which will replace all instances of the placeholders in a template with the actual data.
Try Mustache. (Twitter used it in their recent redesign, so they can share templates between server-side Ruby and client-side JavaScript.)
It's also available in Ruby, JavaScript, Python, Erlang, PHP, Perl, Objective-C, Java, .NET, Android, C++, Go, Lua, ooc, ActionScript, ColdFusion, Scala, Clojure, Fantom, CoffeeScript, D, and for node.js.
(Yes, I know you mentioned it in your question, but this answer has links and stuff.)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With