poper

A friend who replaces content wrapped in specific comments

  • poper

Downloads in past

Stats

StarsIssuesVersionUpdatedCreatedSize
poper
010.1.17 years ago7 years agoMinified + gzip package size for poper in KB

Readme

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 @remrinrin