0.0.2 • Published 8 years ago
mustache-simple v0.0.2
mustache-simple
Dead simple limited mustache compiler
Install
npm install --save mustache-simpleFeatures
- Support nested object map
- Two types of behavior. Full/Partial compile
Usage
compileAllremove all unmatched mustachescompileMatchdon't touch unmatched mustaches. In case pre-preocess partiallyfalse,nullwill be ''undefinedis treated as unmatched- No filter, No escape
Nested Object map
const mustache = require('mustache-simple')
const map = {
foo: 'bar',
hello: 'world'
users: {
bob: {
age: 23
}
}
}
const parser = mustache.compileMatch(config)
const res = parser('The foo is {{foo}}, hello {{hello}}\n Age of bob is {{users.bob.age}}')
// The foo is bar, hello world\n Age of bob is 23Limited words
You can give allowed list of words. Only they are compiled. others will not be changed at all
const parser2 = mustache.compileMatch(config, ['foo', 'users.bob.age'])
const res = parser('The foo is {{foo}}, hello {{hello}}\n Age of bob is {{users.bob.age}}')
// The foo is bar, hello {{hello}}\n Age of bob is 23