---
description: oTree template syntax limits (no parentheses in if)
globs: "**/*.html"
alwaysApply: false
---

# oTree templates (`{{ }}`)

Project uses **oTree 5.11.0**. oTree’s template engine is **not** Jinja2/Django-full.

## Avoid in `{{ if ... }}` / `{{ elif ... }}`

- **Parentheses** grouping: expressions like `{{ if (a or b) and c }}` fail with `TemplateSyntaxError: Unparsable expression ...`.
- Prefer **nested blocks**:

```html
{{ if a or b }}
    {{ if c }}
        ...
    {{ endif }}
{{ endif }}
```

- **`!=` and simple compares** are usually fine; **`and` / `or`** chains without parentheses are fine; when you need both grouping and mixed `and`/`or`, use nesting or compute a boolean in `vars_for_template` / `js_vars` and pass a single variable.

## When logic is too heavy for templates

Expose `show_ai_popover: True/False` (or similar) from the Page’s `vars_for_template` instead of duplicating treatment lists in HTML.
