////////////////////////////////////////////////
// Example of using Razor-Express
// https://www.npmjs.com/package/raz
// in Node.js environment.
////////////////////////////////////////////////
// This is a view-model:
const model = {
title: "Names of the Days of the Week",
days: ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday']
};
// This is a Razor murkup template (HTML mixed with JavaScript):
const template = `
<h3>@Model.title</h3>
<ul>
@for(var i = 0; i < Model.days.length; i++){
var day = Model.days[i];
<li>@day</li>
}
</ul>`;
// Compilation of the model & template into an HTML string.
const razor = require("raz");
var html = razor.compileSync({ model, template });
// Output compiled HTML:
html;