Skip to main content
TemplateDX doesn’t have variable declarations. At render time, the caller passes a props object to transform(); your template reads those values with {props.*} expressions. Tag plugins can introduce additional scoped variables (e.g. <ForEach> gives you the loop iterand).

Accessing variables

Dot notation

Read nested properties with dot notation, same as JavaScript:
{props.username}
{props.user.firstName} {props.user.lastName}

Bracket syntax

Bracket syntax works for dynamic or hyphenated keys:
{props['user-name']}
{props['user-email']}

Undefined-variable behavior

  • Missing nested properties (via MemberExpression) render as empty string:
    {props.user.address.street}   // renders '' if `address` or `street` is missing
    
  • Bare undefined identifiers (no props. prefix) resolve to the literal string "undefined" — the evaluator treats them as undeclared names, not optional chains:
    {someGlobal}   // renders "undefined" if `someGlobal` isn't in scope
    
Only variables provided by the caller’s props, introduced by a tag plugin’s scope (<ForEach>, <If>), or registered filters (see Filters) are accessible. JavaScript globals are not.

Examples

Defined variable

{props.username}
Alice

Nested properties

{props.user.firstName} {props.user.lastName}
Alice Johnson

Bracket syntax for dynamic properties

{props['user-email']}
alice.johnson@example.com

Undefined nested property

{props.user.address.street}
(renders empty string)