BenoitWauthier / simple-placeholder-replacer

MIT License
0 stars 0 forks source link

simple-placeholder-replacer

Build Status Coverage Status dependencies Status devDependencies Status Known Vulnerabilities

Npm version Npm downloads Npm download size Last Commit Contributors

A library to replace placeholders in a json/string object. You have to use double curly brackets {{placeholderKey}} to identify the placeholder and proivide a map with pairs of key / value where the key is the name of the placeholder (case doesn't matter) and value is the replacement value for that placeholder. The library can also handle date / date time placeholders that are {{now}} or {{today}} (again case doesn't matter) and that can be configured with the following options :

Installation

To install with npm:

npm i simple-placeholder-replacer --save

Usage

Usage with node:

var replacePlaceholders = require('simple-placeholder-replacer');

replacePlaceholders('I want {{myPlaceholder}} to be replaced', {myPlaceholder: 'this placeholder'});

--> 'I want this placeholder to be replaced'

replacePlaceholders({"myDate": "{{today+1m=DD MM YYYY}}"});

--> assuming today is the 11-03-2021 : {"myDate": "11 04 2021"}

Release

npm version major / minor / patch
git push origin ${tagName}

License

This is licensed under an MIT License. See details