Substitutions

Substitutions allow you to substitute certain parts of the blueprint with dynamic data. Substitution start with {{ and end with }} tags respectively. You can use any previously defined variable or function combined with transformers to write the value to the output.

Simple substitutions

Substitution can be used simply to write a dynamic value of a specific variable to the output:

{[ var name "Anna" /]}
{[ var points 500 /]}
Current user: {{ name }} ({{ points }} points)

Resulting in the following output:

Current user: Anna (500 points)

Note that any space in substitution tag is ignored, so both {{name}} and {{ name }} produce the same result. The spaced syntax is highly recommended for better readability.

Dot Notation Access

If a variable is a dictionary, you can use dot notation in order to access specific values inside it. This is very useful, especially when working with functions, as they usually return a dictionary as a result. For example, let's take an imaginary function @todaysWeather() and store it into weather variable:

{[ var weather @todaysWeather() /]}

When executed, weather is filled with current weather data, looking like this:

weather = [
"now": 28,
"later": 30,
"days": [
"mon": 10,
"tue": 20
],
"cities": [
["name": "Prague", "temp": 30],
["name": "San Francisco", "temp": 25],
]
]

Then, because weather is now a dictionary, we can use dot notation access to access the specific values:

It is {{ weather.now }}C and it will be {{ weather.later }}C later today.

The rendered output will then look like this:

It is 28C and it will be 30C later today

Nested dictionaries

Dot notation is not limited just to one level, if there is another dictionary, you can use it again, such as in the following definition:

It will be {{ weather.days.mon }} on Monday

Resulting in the following output:

It will be 10C on Monday

Combining arrays and dictionaries

You can always use dot notation, even when the chain didn't start with a dictionary. The only requirement is that you use it on top of the dictionary. This is useful in case of cities key in the example above:

{{ weather.cities.first().name }} currently experiences {{ weather.cities.first().temp }}C

As you can see, we access cities data using dot notation, but then we use array transformer to retrieve the first item in the array. This retrieves dictionary again containing two keys (temp and name) which we can again access using the dot notation.

The output will look like this:

Prague currently experiences 30C