tokenizes a string with mustache variables
npm install tokenstache> A tiny tokenizer for handlebars variables
- Install
- Usage
- Examples
- API
- License
This project uses node and npm. Go check them out if you don't have them locally installed.
``sh`
npm install --save tokenstache
Then with a module bundler like webpack or rollup, use as you would anything else:
`js`
import { tokenize } from 'tokenstache'
The UMD build is also available on unpkg:
`html`
You can find the library on window.tokenstache.
`jshello {{user}}
import { tokenize } from 'tokenstache'
let arr = tokenize(, {user: jim}); // outputs: ['hello', jim]`
##### Table of Contents
- tokenize
#### tokenize
Tokenizes a string that contains handlebars and tries to resolve it
Parameters
- template String The template containing one or more {{variableNames}} every variableview
- (Object \| Function) An object or function that will resolve the values{}
for every variable names that is used in the template. If it's omitted, it'll be set to
an empty object essentially removing all {{varName}}s in the template. (optional, default )
Examples
`javascripthello {{user}}
let arr = tokenize(, {user: jim}); // outputs: ['hello', jim]``
Returns Array Template where its variable names replaced with corresponding values.
Found a problem? Want a new feature? First of all see if your issue or idea has already been reported.
If don't, just open a new clear and descriptive issue.