node package manager
Stop wasting time. Easily manage code sharing in your team. Create a free org »

toybox-js-parse-variables

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

parseString(string, sourceData, templates, defaults, contextPath)Object

Recursively replace instances of %{somevariable} in a string Returns a string or a function that interpolates variables

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

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