poper

0.1.1 • Public • Published

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

Readme

Keywords

none

Package Sidebar

Install

npm i poper

Weekly Downloads

69

Version

0.1.1

License

MIT

Last publish

Collaborators

  • rem