0.1.1 • Published 7 years ago

poper v0.1.1

Weekly downloads
137
License
MIT
Repository
github
Last release
7 years ago

poper

NPM version NPM downloads Build Status donate

Install

yarn add poper

How does it work

It matches a starting comment /* @@variable */ and an ending comment /* variable@@ */, finally it replaces the comments and content within using the data you provide. The variable supports dot path like foo.deep.key

Usage

const poper = require('poper')

const input = `
{
  hello: /* @@foo */ whatever.content(val) /* foo@@ */,
  there: /* @@bar */ what's this? /* bar@@ */
}
`

poper(input, {
  foo: 123,
  bar: 'hahaha'
}, {stringify: true})

//=> output:

{
  hello: 123,
  there: "hahaha"
}

API

poper(input, data, options)

options

stringify

Type: function

Whether to replace matched content with stringified value using JSON.stringify.

Contributing

  1. Fork it!
  2. Create your feature branch: git checkout -b my-new-feature
  3. Commit your changes: git commit -am 'Add some feature'
  4. Push to the branch: git push origin my-new-feature
  5. Submit a pull request :D

Author

poper © egoist, Released under the MIT License. Authored and maintained by egoist with help from contributors (list).

egoistian.com · GitHub @egoist · Twitter @rem_rin_rin

0.1.1

7 years ago

0.1.0

7 years ago