expand-json

0.3.0 • Public • Published

expand-json

Expand templates on JSON

This tool allows you expand templates on a JSON.
It uses Mustache¹ as template engine and has custom helpers.
¹: it doest not escape HTML automatically

Install

npm install expand-json

Usage

import { expandJson } from 'expand-json'
 
const mapping = {
  full_name: '{{name}} {{last_name}}',
  age: '{{age}}'
}
 
const payload = {
  name: 'Thomas',
  last_name: 'Anderson',
  age: '36',
}
 
const json = expandJson(mapping, payload)
 
console.log(json) // { full_name: 'Thomas Anderson', age: '36' }

Roadmap

  • expand templates on json
  • add upper helper: {{#upper}}{{name}}{{/upper}}
  • add custom escaping

Readme

Keywords

Package Sidebar

Install

npm i expand-json

Weekly Downloads

2

Version

0.3.0

License

MIT

Last publish

Collaborators

  • josmardias