evaljson

6.0.4 • Public • Published

evaljson

Build Status npm Version JS Standard

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.

Readme

Keywords

none

Package Sidebar

Install

npm i evaljson

Weekly Downloads

346

Version

6.0.4

License

MIT

Unpacked Size

50.6 kB

Total Files

28

Last publish

Collaborators

  • okunishinishi