json.mustache.js

0.9.4 • Public • Published

json.mustache.js

Circle CI
npm version

##JSON configuration files with interpolated values

#Getting started

###Install it

$ npm install json.mustache.js

###Require it

var template = require('json.mustache.js');

###Add your configuration file (i.e. config/sample.json)

{
  "test": {
    "url": "mongodb://localhost:27017/{{id}}",
    "id": "test-db-name"
  },
  "development": {
    "url": "mongodb://localhost:27017/{{id}}",
    "id": "hookly-development"
  },
  "production": {
    "url": "mongodb://{{id}}:{{secret}}@sub.mongonodes.com:{{port}}/{{db}}",
    "id": "your-username",
    "secret": "your-password",
    "port": 27074
    "db": "your-db"
  }
}

###Use it
```javascript
process.env.NODE_ENV = 'production';
var config = template('config-file.json');
config.url
//=> "mongodb://your-username:your-password@sub.mongonodes.com:27074/your-db"

Package Sidebar

Install

npm i json.mustache.js

Weekly Downloads

0

Version

0.9.4

License

MIT

Last publish

Collaborators

  • bnorton