So I said, narrow the focus.
Your "use case" should be, there's a 22 year old college student
living in the dorms.
How will this software get him laid? - jwz
We’ve released our tiny templating language (calling it a language really is a stretch) as a jquery plugin.
We don’t actually use the plugin because it’s simpler to just include it in your js:
function tache(template, ctx) {
var t = template;
while (true) {
var res = t.replace(
/{{(.*?)}}/,
function (matched,p1,offset,src) { return ctx[p1]; }
);
if (res == t) {
break;
}
t = res;
}
return t;
}
An example of usage?
function popup(popup_name, data) {
data.popup_name = popup_name;
$("body").prepend(
elpad.tache("<div id='{{popup_name}}' class='popup hidden'>\
<h3>Login</h3><form method='POST' action='{{action}}'>\
<input type='text' name='username' value=''/>\
<button name='login'>login</button></form>\
<div></div></div>", data);
);
}