You can use it like so:
var result = compile('Some {{string}}', {string: 'Awesome code'});
result will be 'Some Awesome code'; Or
var result = compile('Some {{string}}');
result will be the compiled template to be used later
function anonymous(o) {
return "Some " + (o["code"]||"") + "";
};
So you could easily do this
document.body.innerHTML = compile('<article><head>{{title}}</head><section>{{content}}</section></article>', {
title: 'Super fast template engine',
content: compile('<div>{{description}}</div>', {
description: 'Small and super fast logic-less template engine in 132 bytes.'
})
})
"{}" as placeholders is problematic for inline css. I would advise to use "{{}}" or "${}" instead.