Espresso

Variables

Syntax

Variables in Dynamo allow you to reuse content, conditionally output markup, and customize mixins or imports.

Variables in Dynamo start with either $ or @, and can contain letters, numbers, and underscores. (Which character you use is a stylistic choice; the two are interchangeable. We recommend using $variableName, however, so that your variables are visually-distinct from Dynamo directives.)

The contents of variables are always strings.

Variables live within a particular scope. For instance, an imported page will receive any variables defined in its parent, but setting those variables within the imported child will not affect the parent file.

Setting variables

There are three ways to set variables: equal sign delimited, colon delimited, and space delimited.

Equal sign delimited

<!-- $someName = someValue -->

Colon delimited

<!-- $someName: someValue -->

Space delimited

<!-- $someName someValue -->

Spacing is not strict--aside from at least one required space for space delimited variables--and the final value will be trimmed, so these are all identical, as far as Dynamo is concerned:

<!-- $someName = someValue -->
<!--$someName=someValue-->
<!-- $someName=	someValue -->

Which format you use is a stylistic choice; we recommend using either equal sign or colon delimited versions, because they are more explicit.

Outputting variables

Output a variable by placing it alone within a comment. For variables that may be empty, you can include default contents after a pipe character:

<!-- $someName -->
<!-- $someName | Some Default Value -->