Heh — the tag choice *is* ugly. But every other character that came in opening/closing pairs seemed to be somehow taken or off-limits. I didn’t realize JS templating engines were so commonplace when I submitted this story– JavaScript Templates in particular (http://code.google.com/p/trimpath/wiki/JavaScriptTemplates) seems to be very well developed, but a different, more Velocity-like, approach than EJS.

When a template is served it can be compiled into JavaScript before it is sent out to the browser.

So a template file myTitle.jhtml

[%= title %]

is compiled server-side into

function myTitle(obj) {
return ”+obj.title+”;
}

Now serve this JavaScript to the browser. There is no need to send the template interpreting engine to the browser.

I believe this is what Perl’s Template::Toolkit does even when used server-side. It first compiles from the template to Perl just once and then uses the compiled version many times after for faster page rendering.

A rant/request, if you will: Please keep important information and data in HTML where it belongs and performs best, rather than creating or serving it via Javascript; search engines, accessibility agents and the internets in general will thank you. :)

(IMHO, you shouldn’t be using Javascript to create “core” HTML content on the client for numerous reasons, performance and otherwise.)

the server has no business creating a client side representation (HTML). the path to usable sites is not adding CSS3 to lynx, its providing everything as ATOM/RDF. it will be much easier for search engines to switch to using this data, than it was for them to get good at gleaning semantics out of HTML (which they still suck at)

now why the obsession with hacking subsets of javascript into custom/nonstandard DOM element attrs, or this sprintf/custom-parser style mix and match hell. people like unreadability?

I’ve been trying to figure out for about a month now why anybody would ever use such a waste of bandwidth and cpu. It just struck me… the same reason that I switched from perl to php and java/jsp so many years ago. The answer, WYSIWYG using designers. Javscript coders are finally becoming sophisticated enough that they have to dumb down what they are doing for the Dreamweaver users of the world. Y

So we have re-created the server-side component of the web on the client side. But tell me, where is the data that will populate the client-side template come from – the server?
The internet will eat itself, I promise.

Comment by Dan — June 6, 2007

Why all these template languages / frameworks? XSLT will do this faster, with much less code, and in a more understandable format on any browser created since IE 6!