CoolFace
Apppublic

AK-21/Graphite-Industrial-Intelligence

sourceHugging Faceupdated 3mo agoView on Hugging Face
0likes
README.md44 linesDownload Raw Back to expand-template
1# expand-template2 3> Expand placeholders in a template string.4 5[![npm](https://img.shields.io/npm/v/expand-template.svg)](https://www.npmjs.com/package/expand-template)6![Node version](https://img.shields.io/node/v/expand-template.svg)7[![Build Status](https://travis-ci.org/ralphtheninja/expand-template.svg?branch=master)](https://travis-ci.org/ralphtheninja/expand-template)8[![JavaScript Style Guide](https://img.shields.io/badge/code_style-standard-brightgreen.svg)](https://standardjs.com)9 10## Install11 12```13$ npm i expand-template -S14```15 16## Usage17 18Default functionality expands templates using `{}` as separators for string placeholders.19 20```js21var expand = require('expand-template')()22var template = '{foo}/{foo}/{bar}/{bar}'23console.log(expand(template, {24  foo: 'BAR',25  bar: 'FOO'26}))27// -> BAR/BAR/FOO/FOO28```29 30Custom separators:31 32```js33var expand = require('expand-template')({ sep: '[]' })34var template = '[foo]/[foo]/[bar]/[bar]'35console.log(expand(template, {36  foo: 'BAR',37  bar: 'FOO'38}))39// -> BAR/BAR/FOO/FOO40```41 42## License43All code, unless stated otherwise, is dual-licensed under [`WTFPL`](http://www.wtfpl.net/txt/copying/) and [`MIT`](https://opensource.org/licenses/MIT).44