Spectrum.js is a JavaScript template language targetted at both the server (e.g. node.js) and the client-side.
It has a lightweight syntax, using embedded JavaScript for logic rather than inventing yet another language to learn. This "logic-ful" template approach ensures that all of you view logic can live within your views, in contrast to the some recent "logic-less" template" systems.
It also borrows heavilly from Mason to achieve high levels of reuse within your templates.
Npm is recommended for development, although for production you might want to find/build a package for your operating system:
npm install spectrum
Create a views/index.spv
file within a node.js project, containing the following:
<~inherit none />
one plus one is <%= 1 + 1 %>
This template can be rendered with the following code. Adjust the file paths as appropriate.
var Spectrum = require('spectrum');
var view = new Spectrum.Renderer(__dirname + '/../views');
view.render('/index.spv', {}).then(function (output) {
// rendered content is available in the output variable
});
This example assumes that the file you invoke it from is in a directory that is a sibling of the views directory.
You can use Spectrum with Micro.