I have experimented with several of the template engines that work with Express. I am looking for an engine that can work in a single HTML file by adding the CDN link; in other words, a non-Node project, no WebPack, no Gulp files. Just an HTML and javascript files.
So far, I’ve found that Mustache can do this. Are there any others that can do this? I have been googling for a list of engines but have not found one yet.
Advertisement
Answer
You should take a look at pure.js
It allows you to parse html templates just with the use of javascript. No node, webpack or other things.
The template:
JavaScript
x
4
1
<div>
2
Hello <span></span>
3
</div>
4
How to render it:
JavaScript
1
10
10
1
var data = {
2
who:'BeeBole!' //the JSON data
3
},
4
5
directive = {
6
'span':'who' //make the link between the HTML SPAN tag and the JSON property "who".
7
};
8
9
$( 'div' ).render( data, directive ); //render the result
10