Skip to content

Instantly share code, notes, and snippets.

@ThomasPe
Created July 30, 2018 11:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ThomasPe/02e0c55c0a925c5492b7c5c026963e08 to your computer and use it in GitHub Desktop.
Save ThomasPe/02e0c55c0a925c5492b7c5c026963e08 to your computer and use it in GitHub Desktop.
Render index.html from mustache templates & dynamic data
function renderSite(){
context.log("render site");
var pageFile = "";
mu.compileText('index.mustache', context.bindings.indexTemplate, function (err, parsed) {
var renderstream = mu.render(parsed, { news: mynews, links: mylinks });
renderstream.on('data', function (data) {
pageFile += data;
});
renderstream.on('end', function (data) {
context.log("done creating index.html");
uploadSite(pageFile);
});
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment