Jemplateでcompileすると何が出てくるのか
気になったのは変換(compile)すると何が出てくるのか、で。
# jemplate --compile test.tt
を実際やってみた。
元HTMLは、
<h1>[% title %]</h1> <p>[% description %]</p> <p>foo</p>
これを変換すると、こうなります。
Jemplate.templateMap['test.tt'] = function(context) {
if (! context)
throw('Jemplate function called without context\n');
var stash = context.stash;
var output = '';
var error = null;
try {
output += '<h1>';
//line 1 "test.tt"
output += stash.get('title');
output += '</h1>\n\n<p>';
//line 3 "test.tt"
output += stash.get('description');
output += '</p>\n\n<p>foo</p>\n';
}
catch(e) {
error = context.katch(e, output);
if (error.type != 'return')
throw(error);
}
return output;
}
なかなか面白そうなモジュールで、さっそくmiyagawaさんが、Catalyst::Viewにしてたりします。
templatizeはクライアント側で、というのがこれからになったりするのでしょうか。