micro-engine

0.0.1 • Public • Published

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

Readme

Keywords

none

Package Sidebar

Install

npm i micro-engine

Weekly Downloads

249

Version

0.0.1

License

BSD-2-Clause

Last publish

Collaborators

  • kaiquewdev