---
title: Templates
description: "Extract reusable statement flows into template files and include them with the template field, with params substituted at transpile time."
---

# Templates

<div class="view-markdown-wrapper">
<ViewMarkdown />
</div>

Extract reusable flows into template files and include them with `template:`.

### Template file (`templates/login.yaml`):

```yaml
params:
  - username
  - password

statements:
  - intent: Enter username
    action: input_text
    locator: "getByLabel('Username')"
    text: "<<username>>"
  - intent: Enter password
    action: input_text
    locator: "getByLabel('Password')"
    text: "<<password>>"
  - intent: Click login
    action: click
    locator: "getByRole('button', { name: 'Log in' }).first()"
```

### Using the template:

```yaml
goal: Purchase flow
base_url: https://example.com

statements:
  - URL: /
  - template: ../templates/login.yaml
    params:
      username: "{{TEST_USER}}"
      password: "{{TEST_PASS}}"
  - intent: Navigate to the checkout page
  - VERIFY: Order summary is displayed
```

Template params (`<<username>>`) are substituted at transpile time. Environment variables (<code v-pre>{{TEST_USER}}</code>) pass through to the generated code for runtime resolution.

Templates can be nested (max depth: 5) and circular references are detected.
