node-underscore-html-generator
v1.0.0
Published
Takes a data object, an underscore template and returns the populated template.
Downloads
4
Readme
#Node-Underscore-HTML-Generator Pass in a json data object and the path to the Underscore template you want to populate. Returns a data object with property 'html' which contains the populated template.
Installation
npm install node-underscore-html-generator --save
Usage
var NodeUndrsc = require('node-underscore-html-generator');
// Then in your code where necessary
//@params {string} - filePath Path to the file containing the template
//@params {object} - json object Object containing the data to populate the template
var filePath = 'path/to/my/template.html';
var jsonObject = {
"name": "Jackie",
"email": "[email protected]"
};
NodeUndrsc.generateHtml(filePath, jsonObject, function (err, dataObject) {
if (err) {
// ... manage the error
return;
}
/*
dataObject = {
html: "<html>...."
}
*/
var populatedHtml = dataObject.html;
console.log(populatedHtml);
});
Testing
npm test