reversible-template-string

1.0.0 • Public • Published

reversible-template-string

Encode and decode data to string using mustache-like template strings

Usage

Functions

encodeTemplate(template, values)String

Encode a template with the given variables. NOTE: values must not include curly braces or commas.

decodeTemplate(template, string)Object

Decode a template string given the given template.

encodeTemplate(template, values) ⇒ String

Encode a template with the given variables. NOTE: values must not include curly braces or commas.

Kind: global function
Returns: String - The template with the values encoded. E.g. 'employee_12_months_growth'

Param Type Description
template String Template string. E.g. 'employee_{period}_months_growth'
values String Object of values to insert in the string. E.g. { period: 12 }

decodeTemplate(template, string) ⇒ Object

Decode a template string given the given template.

Kind: global function
Returns: Object - An object given the matched template values. E.g. { period: '12' }

Param Type Description
template String Template string. E.g. 'employee_{period}_months_growth'
string String A string to be decoded with the given template. E.g. 'employee_12_months_growth'

Package Sidebar

Install

npm i reversible-template-string

Weekly Downloads

219

Version

1.0.0

License

MIT

Unpacked Size

13.3 kB

Total Files

6

Last publish

Collaborators

  • ashkyd