1.0.0 • Published 4 years ago
reversible-template-string v1.0.0
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.
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' |
1.0.0
4 years ago