Re:PaJes, Simple JavaScript Templating Library for generatin...
by Maciek416 on Thursday December 31, 2009 @10:45AM
(#1024410)
Thanks for making this also work in nodejs. I've tried Mustache and hamljs, and I'll have to give your code a whirl as well.
(btw: Is it possible to call within a namespace, i.e. pjs.DIV( .. ), as opposed to DIV(..) ? Your examples seem to export the tags and forEach as globals).
var model = [ {name: "Lisa Simpson", id: 1}, {name: "Bart Simpson", id: 666} ]
DIV( {id:"demo-div", width: "60%"}, OL( {style: "list-style-type: upper-roman"}, forEach(model, studentDetails) ) ).display(out); out.flush();
function studentDetails(index, value) { return LI( value.name, A( {href:"/student-details?id="+value.id}, "details "+(index+1) ) ); }
(btw: Is it possible to call within a namespace, i.e. pjs.DIV( .. ), as opposed to DIV(..) ? Your examples seem to export the tags and forEach as globals).
For example,
This requires CommonJS module system to be in place (that is, function require() being implemented to be specific).Alternatively, it would be trivial to make non-CommonJS use namespace too by modifying PaJes.js. Do you need namespace in non-CommonJs setting?
Thanks for trying it out!