source: node_modules/expand-template/README.md@ 62b2964

finki-main main
Last change on this file since 62b2964 was 81bc7da, checked in by Klimentina Efremova <klimentina08642@…>, 3 months ago

Initial commit

  • Property mode set to 100644
File size: 1.2 KB
Line 
1# expand-template
2
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## Install
11
12```
13$ npm i expand-template -S
14```
15
16## Usage
17
18Default functionality expands templates using `{}` as separators for string placeholders.
19
20```js
21var 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/FOO
28```
29
30Custom separators:
31
32```js
33var 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/FOO
40```
41
42## License
43All code, unless stated otherwise, is dual-licensed under [`WTFPL`](http://www.wtfpl.net/txt/copying/) and [`MIT`](https://opensource.org/licenses/MIT).
Note: See TracBrowser for help on using the repository browser.