0.0.1 • Published 12 years ago

instantiator v0.0.1

Weekly downloads
4
License
-
Repository
github
Last release
12 years ago

JS Instantiator

Takes a JS object template and a list of bindings to create an object with bindings replaced.

Build Status

Example Usage

var instan = require('instantiator');
var template = { $a: '$x', $x: ['$y', '$z'], abc: 123 };
var bindings = { $a: 'hello', $x: 'world', $y: 'wide', $z: 'web' };
var obj = instan(template, bindings);
// Result: { hello: 'world', world: ['wide', 'web'], abc: 123 }

API

Module provides a single function that has the following signature.

  1. template - template object. Should have $var strings in places that should be replaced. (can be keys or string values)
  2. bindings - object with bindings that have the replace values for the $vars in the template object.