const testProcHtmlTemp = require("processhtmltemplate");
// Define template
let myTemplateHTML = '<!doctype html><h1>Congratulation those clients win a prize!</h1><html><% _.forEach(users, function(user) { %><li><%- user %></li><% }); %><p>Country of origin : <%= continent.country[1] %></p><h4>You can participate every week.</h4><hr/><p>This has been generated with processhtmltemplate a node module from inbedia.</p></html>';
// Define Data in JSON
let myTemplateDataUser = { 'users': ['Fred Flimstone', 'Barney Nockeles', "Bill Belechek", "Mat Groening"], continent: { country: ["Canada", "USA", "Mexico"] } };
testModuleTemplateHTMLCB();
// With callback
function testModuleTemplateHTMLCB() {
console.log(`Test start ----------------`);
console.log("1st test normal one with callback...");
// Normal using callback
let testHTMLtemplateCB = new testProcHtmlTemp.InbediaModule.ProcessHTMLTemplate(myTemplateHTML, myTemplateDataUser);
testHTMLtemplateCB.ProcessHTML((resString) => {
if (typeof resString === "string")
console.log("Merge result = " + resString);
else
console.log("Error has been generated !");
});
}
Created from: https://npm.runkit.com/processhtmltemplate