To generate HTML with JavaScript, we use Mustache.
For instance, we write
const view = {
url: "/hello",
name: () => {
return "Jo" + "hn";
},
};
const output = Mustache.render(
'<div><img src="{{url}}" />{{name}}</div>',
view
);
to call Mustache.render
with the Mustache template and the view
object with the values for the url
and name
placeholders.