{"_id":"replaces","_rev":"268215","name":"replaces","description":"Micro template engine that can automatically escape data.","dist-tags":{"latest":"1.0.2"},"maintainers":[{"name":"3rdeden","email":""}],"time":{"modified":"2023-06-28T11:58:06.000Z","created":"2015-03-13T15:57:57.890Z","1.0.2":"2015-06-22T11:59:28.864Z","1.0.1":"2015-03-16T11:46:48.935Z","1.0.0":"2015-03-16T08:12:01.016Z","0.0.0":"2015-03-13T15:57:57.890Z"},"users":{},"author":{"name":"Arnout Kazemier"},"repository":{"type":"git","url":"git+https://github.com/bigpipe/replaces.git"},"versions":{"1.0.2":{"name":"replaces","version":"1.0.2","description":"Micro template engine that can automatically escape data.","main":"index.js","scripts":{"100%":"istanbul check-coverage --statements 100 --functions 100 --lines 100 --branches 100","test":"mocha test.js","watch":"mocha --watch test.js","coverage":"istanbul cover ./node_modules/.bin/_mocha -- test.js","test-travis":"istanbul cover node_modules/.bin/_mocha --report lcovonly -- test.js"},"repository":{"type":"git","url":"git+https://github.com/bigpipe/replaces.git"},"keywords":["replace","repaces","template","engine","micro","tag","escape","json","stringify","encode","templates","waffles"],"author":{"name":"Arnout Kazemier"},"license":"MIT","bugs":{"url":"https://github.com/bigpipe/replaces/issues"},"homepage":"https://github.com/bigpipe/replaces","devDependencies":{"assume":"1.1.x","istanbul":"0.3.x","mocha":"2.2.x","pre-commit":"1.0.x"},"dependencies":{"json-stringify-safe":"5.0.x","propget":"1.0.x"},"gitHead":"3f7a7e009f4b46d50e7d3fb7bd233cb3afc0674e","_id":"replaces@1.0.2","_shasum":"8f840ba74d457061ec302db4e91d86107bf7dde7","_from":".","_npmVersion":"2.9.1","_nodeVersion":"0.12.3","_npmUser":{"name":"3rdeden","email":"npm@3rd-Eden.com"},"maintainers":[{"name":"3rdeden","email":""}],"dist":{"shasum":"8f840ba74d457061ec302db4e91d86107bf7dde7","size":4106,"noattachment":false,"key":"/replaces/-/replaces-1.0.2.tgz","tarball":"http://name.csiicloud.com:7001/replaces/download/replaces-1.0.2.tgz"},"directories":{},"_cnpmcore_publish_time":"2021-12-19T13:25:16.234Z","publish_time":1434974368864,"_cnpm_publish_time":1434974368864},"1.0.1":{"name":"replaces","version":"1.0.1","description":"Micro template engine that can automatically escape data.","main":"index.js","scripts":{"100%":"istanbul check-coverage --statements 100 --functions 100 --lines 100 --branches 100","test":"mocha test.js","watch":"mocha --watch test.js","coverage":"istanbul cover ./node_modules/.bin/_mocha -- test.js","test-travis":"istanbul cover node_modules/.bin/_mocha --report lcovonly -- test.js"},"repository":{"type":"git","url":"https://github.com/bigpipe/replaces"},"keywords":["replace","repaces","template","engine","micro","tag","escape","json","stringify","encode","templates","waffles"],"author":{"name":"Arnout Kazemier"},"license":"MIT","bugs":{"url":"https://github.com/bigpipe/replaces/issues"},"homepage":"https://github.com/bigpipe/replaces","devDependencies":{"assume":"1.1.x","istanbul":"0.3.x","mocha":"2.2.x","pre-commit":"1.0.x"},"dependencies":{"json-stringify-safe":"5.0.x"},"gitHead":"4a6651a800e8a5ffda332739b3c93de40fd0290b","_id":"replaces@1.0.1","_shasum":"740ce8ecd654c42e321ca4553fc7600b5a117ea3","_from":".","_npmVersion":"2.3.0","_nodeVersion":"0.10.35","_npmUser":{"name":"3rdeden","email":"npm@3rd-Eden.com"},"maintainers":[{"name":"3rdeden","email":""}],"dist":{"shasum":"740ce8ecd654c42e321ca4553fc7600b5a117ea3","size":4319,"noattachment":false,"key":"/replaces/-/replaces-1.0.1.tgz","tarball":"http://name.csiicloud.com:7001/replaces/download/replaces-1.0.1.tgz"},"directories":{},"_cnpmcore_publish_time":"2021-12-19T13:25:15.345Z","publish_time":1426506408935,"_cnpm_publish_time":1426506408935},"1.0.0":{"name":"replaces","version":"1.0.0","description":"Micro template engine that can automatically escape data.","main":"index.js","scripts":{"100%":"istanbul check-coverage --statements 100 --functions 100 --lines 100 --branches 100","test":"mocha test.js","watch":"mocha --watch test.js","coverage":"istanbul cover ./node_modules/.bin/_mocha -- test.js","test-travis":"istanbul cover node_modules/.bin/_mocha --report lcovonly -- test.js"},"repository":{"type":"git","url":"https://github.com/bigpipe/replaces"},"keywords":["replace","repaces","template","engine","micro","tag","escape","json","stringify","encode","templates","waffles"],"author":{"name":"Arnout Kazemier"},"license":"MIT","bugs":{"url":"https://github.com/bigpipe/replaces/issues"},"homepage":"https://github.com/bigpipe/replaces","devDependencies":{"assume":"1.1.x","istanbul":"0.3.x","mocha":"2.2.x","pre-commit":"1.0.x"},"dependencies":{"json-stringify-safe":"5.0.x"},"gitHead":"4a7d4fd0309d5d6edd89c7cfd3cf44f54af046b4","_id":"replaces@1.0.0","_shasum":"16d0ff9f2b65fa4a8d54456500c697809a980487","_from":".","_npmVersion":"2.3.0","_nodeVersion":"0.10.35","_npmUser":{"name":"3rdeden","email":"npm@3rd-Eden.com"},"maintainers":[{"name":"3rdeden","email":""}],"dist":{"shasum":"16d0ff9f2b65fa4a8d54456500c697809a980487","size":4234,"noattachment":false,"key":"/replaces/-/replaces-1.0.0.tgz","tarball":"http://name.csiicloud.com:7001/replaces/download/replaces-1.0.0.tgz"},"directories":{},"_cnpmcore_publish_time":"2021-12-19T13:25:14.481Z","publish_time":1426493521016,"_cnpm_publish_time":1426493521016},"0.0.0":{"name":"replaces","version":"0.0.0","description":"Micro template engine that can automatically escape data.","main":"index.js","scripts":{"100%":"istanbul check-coverage --statements 100 --functions 100 --lines 100 --branches 100","test":"mocha test.js","watch":"mocha --watch test.js","coverage":"istanbul cover ./node_modules/.bin/_mocha -- test.js","test-travis":"istanbul cover node_modules/.bin/_mocha --report lcovonly -- test.js"},"repository":{"type":"git","url":"https://github.com/bigpipe/replaces"},"keywords":["replace","repaces","template","engine","micro","tag","escape","json","stringify","encode","templates","waffles"],"author":{"name":"Arnout Kazemier"},"license":"MIT","bugs":{"url":"https://github.com/bigpipe/replaces/issues"},"homepage":"https://github.com/bigpipe/replaces","devDependencies":{"assume":"1.1.x","istanbul":"0.3.x","mocha":"2.2.x","pre-commit":"1.0.x"},"dependencies":{"json-stringify-safe":"5.0.x"},"gitHead":"40f3938f57cd0a797bb3d8f2853189afd04efde0","_id":"replaces@0.0.0","_shasum":"5720da3ef69a7c692cb3825485d9f0a2c2d1d503","_from":".","_npmVersion":"2.3.0","_nodeVersion":"0.10.35","_npmUser":{"name":"3rdeden","email":"npm@3rd-Eden.com"},"maintainers":[{"name":"3rdeden","email":""}],"dist":{"shasum":"5720da3ef69a7c692cb3825485d9f0a2c2d1d503","size":3236,"noattachment":false,"key":"/replaces/-/replaces-0.0.0.tgz","tarball":"http://name.csiicloud.com:7001/replaces/download/replaces-0.0.0.tgz"},"directories":{},"_cnpmcore_publish_time":"2021-12-19T13:25:13.610Z","publish_time":1426262277890,"_cnpm_publish_time":1426262277890}},"readme":"# replaces\n\n[![From bigpipe.io][from]](http://bigpipe.io)[![Version npm][version]](http://browsenpm.org/package/replaces)[![Build Status][build]](https://travis-ci.org/bigpipe/replaces)[![Dependencies][david]](https://david-dm.org/bigpipe/replaces)[![Coverage Status][cover]](https://coveralls.io/r/bigpipe/replaces?branch=master)\n\n[from]: https://img.shields.io/badge/from-bigpipe.io-9d8dff.svg?style=flat-square\n[version]: http://img.shields.io/npm/v/replaces.svg?style=flat-square\n[build]: http://img.shields.io/travis/bigpipe/replaces/master.svg?style=flat-square\n[david]: https://img.shields.io/david/bigpipe/replaces.svg?style=flat-square\n[cover]: http://img.shields.io/coveralls/bigpipe/replaces/master.svg?style=flat-square\n\nReplaces is a micro library that moves the data formatting instructions to the\ntemplate placeholders using special modifier chars.\n\n## Installation\n\nThis module should work server-side and client side using the commonjs module\nsystem. The module it self is released in the public npm registry and can be\ninstalled by running:\n\n```\nnpm install --save replaces\n```\n\n## Usage\n\nThe module only exposes one single interface, which is a function that requires\n3 arguments:\n\n1. The template string that contains the tags that should be replaced.\n2. A Regular Expression that has 2 capturing groups:\n  1. First group should capture the data modifier which can be `\\W+`\n  2. The second group is the name of the key that should be used to extract the\n     data from the supplied data argument.\n3. The data object which contains all the information.\n\n```js\n'use strict';\n\nvar replaces = require('replaces')\n  , template = require('fs').readFileSync(__dirname +'/template.html', 'utf-8');\n\nconsole.log(replaces(template, /{fittings(\\W+)([^}]+?)}/g, {\n  data: 'structure',\n  deeply: {\n    nested: {\n      data: 'structures'\n    }\n  }\n}));\n```\n\nWhere `template.html` would be:\n\n```html\n<div>{fittings:deeply.nested.data}</div>\n<div>{fittings@deeply}</div>\n```\n\nWould produce the following output in the console.\n\n```\n<div></div>\n<div>{\"nested\":{\"data\":\"structures\"}}</div>\n```\n\n### Modifiers\n\nThe template tags can use various of modifiers. \n\n- **`<>`** Make sure that the data we're trying to add to the template is save\n  to use inside of HTML tags.\n- **`~`** Transform the receiving data in to a JSON.stringify structure.\n- **`@`** Transform the receiving data in to a JSON.stringify structure\n  **without** crashing on circular references like a normal stringify operation\n  would.\n- **`$`** Transform the data using the circular JSON parser and ensure that\n  every value inside the JSON is encoded using the `<>` modifier.\n- **`%`** Escape the data using the `escape` function.\n- Any other non `\\W` is just ignored and will indicated that the data should\n  just be pasted in as normal.\n\nNew modifier can easily be added by adding new properties to the\n`replaces.modifiers` object. The `key` of the object should the be modifier it's\ntriggered by and the value should be a function that transforms the data. The\ntransformer function receives 2 arguments:\n\n1. The key that was used to retrieve the data\n2. Data the key will be replaced with.\n\nThe function should **always** return a string.\n\n## License\n\nMIT\n","_attachments":{},"homepage":"https://github.com/bigpipe/replaces","bugs":{"url":"https://github.com/bigpipe/replaces/issues"},"license":"MIT"}