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 | [](https://www.npmjs.com/package/expand-template)
|
|---|
| 6 | 
|
|---|
| 7 | [](https://travis-ci.org/ralphtheninja/expand-template)
|
|---|
| 8 | [](https://standardjs.com)
|
|---|
| 9 |
|
|---|
| 10 | ## Install
|
|---|
| 11 |
|
|---|
| 12 | ```
|
|---|
| 13 | $ npm i expand-template -S
|
|---|
| 14 | ```
|
|---|
| 15 |
|
|---|
| 16 | ## Usage
|
|---|
| 17 |
|
|---|
| 18 | Default functionality expands templates using `{}` as separators for string placeholders.
|
|---|
| 19 |
|
|---|
| 20 | ```js
|
|---|
| 21 | var expand = require('expand-template')()
|
|---|
| 22 | var template = '{foo}/{foo}/{bar}/{bar}'
|
|---|
| 23 | console.log(expand(template, {
|
|---|
| 24 | foo: 'BAR',
|
|---|
| 25 | bar: 'FOO'
|
|---|
| 26 | }))
|
|---|
| 27 | // -> BAR/BAR/FOO/FOO
|
|---|
| 28 | ```
|
|---|
| 29 |
|
|---|
| 30 | Custom separators:
|
|---|
| 31 |
|
|---|
| 32 | ```js
|
|---|
| 33 | var expand = require('expand-template')({ sep: '[]' })
|
|---|
| 34 | var template = '[foo]/[foo]/[bar]/[bar]'
|
|---|
| 35 | console.log(expand(template, {
|
|---|
| 36 | foo: 'BAR',
|
|---|
| 37 | bar: 'FOO'
|
|---|
| 38 | }))
|
|---|
| 39 | // -> BAR/BAR/FOO/FOO
|
|---|
| 40 | ```
|
|---|
| 41 |
|
|---|
| 42 | ## License
|
|---|
| 43 | All 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.