In programming web applications is often useful to be able to have a templating function.
This is a templating function (rather a library) that aligns with avoiding complexity, safety by design and separation of concerns.
...
Code Block | ||
---|---|---|
| ||
var MAINtemplate= `<p>$Name$ has $$$Amount$ in their bank account.</p>$`p>$ <p>----</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); |
...
Code Block |
---|
Fred has $55 in their bank account. ---- Mary has $45 in their bank account. ---- |
TEMexpand is implemented couple of dozen lines of code. You can get the source here.
...