Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Template language that works on both server and client

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.

like image 370
clyfe Avatar asked Feb 12 '11 10:02

clyfe


People also ask

Is JavaScript client or server-side language?

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.

What is server-side templating language?

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.

What is client-side templating?

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.


1 Answers

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.)

like image 187
AlexChaffee Avatar answered Oct 09 '22 22:10

AlexChaffee