A module to make ES6 templates work non-literally so you can load templates from strings, files, DOM Elements, etc.
npm install non-literal --save
var nonLiteral = require('non-literal'),
// this string could be read from a file, database, localization mechanism, etc.
template = 'Hi ${name}, your score was ${score}!',
model = {
name: "Mike",
score: 97
};
console.log(nonLiteral.render(model, template));
Using renderHtml() ${ }
will encode html entities, $${ }
will output 'raw', without encoding
var nonLiteral = require('non-literal'),
// this string could be read from a file, database, localization mechanism, etc.
template = '<section><strong>${label}:</strong> ${content} $${markup}</section>',
model = {
label: "Message",
content: "Rain storms & silence are my <mind palace>",
markup: "😎"
};
console.log(nonLiteral.renderHtml(model, template));