Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 15 Next »

This a templating function (rather a library) that aligns with goals of doing things simply from first principles.

This is how one would use such a template:

var MAINtemplate=
`<p>$Name$ has $$$Amount$ in their bank account.</p>$`;

function MAINrun(){
   var Body = document.querySelector('body');
   var Data = [{Amount : 55, Name : " Fred " }, {Amount : 45 , Name : "Mary"}];
   Body.innerHTML = TEMexpand(Data, MAINtemplate);
}

READYevent(MAINrun);

This code would produce:

Fred has $55 in their bank account.
Mary has $45 in their bank account.

TEMexpand is implemented in about 20 lines of code. You can get the source here.

So why use this instead of a fully featured templating system like Mustache?

  • No labels