Global

Methods

templex(template, …argsopt)

Merges values of execution context properties named in template by {prop1}, {prop2}, etc., or any javascript expression incorporating such prop names. The context always includes the global object. In addition you can specify a single context or an array of contexts to search (in the order given) before finally searching the global context.

Merge expressions consisting of simple numeric terms, such as {0}, {1}, etc., deref the first context given, which is assumed to be an array. As a convenience feature, if additional args are given after template, arguments is unshifted onto the context array, thus making first additional arg available as {1}, second as {2}, etc., as in templex('Hello, {1}!', 'World'). ({0} is the template so consider this to be 1-based.)

If you prefer something other than braces, redefine templex.regexp.

See tests for examples.

Parameters:
Name Type Attributes Description
template string
args string <optional>
<repeatable>