> For the complete documentation index, see [llms.txt](https://docs.pixiebrix.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.pixiebrix.com/developing-mods/developer-concepts/text-template-guide/template-examples.md).

# Template Examples

### Using variable paths that contain spaces in their names

Let’s assume a brick produces an output called `@userPreferences` and you want to reference the `favorite color` in a text template.

In the Page Editor Data Panel, the Output Data Tab might show:

Example Output Tab of the Data Panel showing data with names that include spaces.

To use the favorite color in a text template expression, **you must use square brackets and quotation marks**:

```
Your favorite color is {{ @userPreference.data["favorite color"] }}
```

### Text substitution using the replace filter

To replace all occurrences of a word or phrase, use the `replace` filter. For example, to replace all occurrences of `bricks` with `brix`:

```
{{ @description | replace("bricks", "brix") }}
```

### Chaining multiple filters in an expression

You can chain multiple filters using the `|` pipe operator. For example:

```
{{ "Lorem ipsum dolor sit amet" | truncate(15) | title }}
```

Will produce the following text output:

```
Lorem Ipsum...
```

### Looping over elements of an array

You can use the [for tag](https://mozilla.github.io/nunjucks/templating.html#for) to loop over elements of an array. This is handy for creating bulleted lists in inputs that support Markdown, such as the Render Markdown brick

```
{% for @item in @items %}
- {{ @item }}
{% endfor %}
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.pixiebrix.com/developing-mods/developer-concepts/text-template-guide/template-examples.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
