micro-engine
v0.0.1
Published
Micro template engine
Downloads
1,167
Readme
Micro
Description
A tiny template engine, with javascript execution isolation.
Purpose
Just for fun.
Installation
[sudo] npm i micro-engine
Usage API
Calling the module
var micro = require('micro-engine');
Definition
var content = micro('{{ message }}');
Compile
content.compile({ message: 'Hello World!' });
// Hello World!
Run
var content = micro('{{ var result = firstValue + secondValue; }}');
content.run({
firstValue: 2,
secondValue: 3
});
// {
// firstValue: 2,
// secondValue: 3,
// result: 5,
// _compiled: "var result = 2 + 3;"
// }
Render
var content = micro('{{ var result = firstValue + secondValue; }}');
content.render({
firstValue: 2,
secondValue: 3
}, '{{ result, firstValue, secondValue }}');
// 5, 2, 3
Working with files
some-file.mic
-------------
{{ var result = firstValue + secondValue; }}
var content = micro.file( './some-file' );
content.render({
firstValue: 2,
secondValue: 3
}, '{{ result, firstValue, secondValue }}');
// 5, 2, 3
License
Under BSD