http://github.com/jquery/jquery-tmpl
http://docs.djangoproject.com/en/dev/topics/templates/
- no program logic in templates
- no embeded script language like in ejs
- this is evil because it enables program logic in templates
- bad usability
- because of the "var" problem in javascript - very very evil
- extendable - you can implement new statements
- html escaping per default
- simple syntax
- NO PROGRAM LOGIC :)
- extendable :)
- tiny and fast
- jquery conform in the future
var jqtpl = require( "jqtpl" );
Want to use it with Express? app.set( "view engine", "html" ); app.register( ".html", require( "jqtpl" ) );
<div>${a}</div>
jqtpl.render( tpl, {a:123});
<div>123</div>
<div>${a}</div>
jqtpl.render( tpl, [{a:1},{a:2},{a:3}]);
<div>1</div><div>2</div><div>3</div>
<div>${a}</div>
jqtpl.render( tpl, {
a:function() {
return 1 + 5;
}
});
<div>6</div>
{{if a == 6}}
<div>${a}</div>
{{else}}
<div>a is not 6</div>
{{/if}}
jqtpl.render( tpl, {a:6});
<div>6</div>
jqtpl.render( tpl, {a:5});
<div>a is not 6</div>
{{each(i, name) names}}
<div>${i}.${name}</div>
{{/each}}
jqtpl.render( tpl, {names: ["A", "B"]});
<div>0.A</div><div>1.B</div>
<div>{{html a}}</div>
jqtpl.render( tpl, {a:'<div id="123">2</div>'});
<div id="123">2</div>
$ node test/test.js
npm install jqtpl