evaljson
v6.0.4
Published
Eval embedded value in json. Useful to define message resource object.
Downloads
4,967
Readme
evaljson
Eval embedded value in json. Useful to define message resource object.
Installation
npm install evaljson --save
Usage
'use strict'
const evaljson = require('evaljson')
let locale = evaljson({
keys: {
NAME: 'My Awesome App'
},
titles: {
WELCOME_TITLE: 'Welcome to #{keys.NAME}!', // Embed value with "#{some_value}" syntax.
WHERE_WE_ARE: 'We are on $(hostname)' // Execute command with "$(command)" syntax
}
/* ... */
})
console.log(locale.titles.WELCOME_TITLE) // -> Welcome to My Awesome App!
API
| Signature | Description | | --------- | ----------- | | evaljson(src) | Eval src, with self values as context. | | evaljson(src, context) | Eval with self values with context. |
License
This software is released under the MIT License.