toybox-js-parse-variables
v0.2.7
Published
Converts variable markers to functions.
Downloads
16
Readme
Convert variables inside %{} markers within strings to functions that return interpolated variables.
Functions
parseData(data, sourceData, templates, defaults, contextPath) ⇒ Object
Recursively replaces %{variable} references with functions Returns the transformed data object
Kind: global function
| Param | Type | | --- | --- | | data | Object | | sourceData | Object | | templates | Object | | defaults | Object | | contextPath | String |
parseString(string, sourceData, templates, defaults, contextPath) ⇒ Object
Recursively replace instances of %{somevariable} in a string Returns a string or a function that interpolates variables
Kind: global function
| Param | Type | | --- | --- | | string | String | | sourceData | Object | | templates | Object | | defaults | Object | | contextPath | String |
interpolateVar(varName, sourceData, templates, defaults, contextPath) ⇒ Object
Given a variable name and source data, returns the closest matching value in source data, or an empty string
Kind: global function
| Param | Type | | --- | --- | | varName | String | | sourceData | Object | | templates | Object | | defaults | Object | | contextPath | String |