Moe-js v0.3

Compiling Templates

Before executing a template, you must first compile it.

// Import moe
const moe = require('@toptensoftware/moe-js');

// Compile a template from a string
let template = moe.compile("<h1>{{}}</h1>");

Or compile from a file (the template will be cached so subsequent calls will re-use the same template)

moe.compileFile("", "UTF8", function(err, template) {


Or, do it synchronously

let template = moe.compileFileSync("", "UTF8");

Or, using async/await:

let template = await moe.compileFileAsync("", "UTF8");

Once you have a template, you can execute it:

let html = template({ name: "Hello, from Moe-js"});
assert(html == "<h1>Hello, from Moe-js</h1>")

Subscribe for more like this. No spam, just fun tech stuff :)

Or, find me on Twitter: @toptensoftware.