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}!',
WHERE_WE_ARE: 'We are on $(hostname)'
}
})
console.log(locale.titles.WELCOME_TITLE)
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.