tarima

Multi-templating for NodeJS

npm install tarima
5 downloads in the last day
5 downloads in the last week
55 downloads in the last month

Precompile your templates with style:

config.json.hbs.us

{
  "<%= target %>": {
    {{#options}}
    "{{<%= key %>}}": "{{<%= val %>}}"{{#unless @last}},{{/unless}}
    {{/options}}
  }
}

script.js

// runtime-jade, handlebars-runtime and less MUST be included to run at client-side
var config = require('tarima').load('config.json.hbs.us');

var data = {
  target: 'main',
  key: 'field',
  val: 'value',
  options: [
    { field: 'item', value: 'something' },
    { field: 'other', value: 'setting' }
  ]
};

var fs = require('fs');

fs.writeFileSync('config.json.hbs', 'module.exports = ' + config.compile(data) + ';');
fs.writeFileSync('config.json', config.render(data));

var test = JSON.parse(fs.readFileSync('config.json'));

console.log(test.main.other == 'setting'); // true

Build Status

npm loves you