# Syntax

URL: /kida/docs/syntax/
Section: syntax
Description: Kida template language syntax for HTML templates, inheritance, filters, and control flow

---

> For a complete page index, fetch /kida/llms.txt.

Kida's template syntax for expressions, control flow, inheritance, filters, and
composition.

## Quick Reference

| Element | Syntax | Example |
|---------|--------|---------|
| Output | `{{ expr }}` | `{{ user.name }}` |
| Tags | `{% tag %}` | `{% if %}`, `{% for %}` |
| Block end | `{% end %}` | Unified ending |
| Comments | `{# text #}` | `{# TODO #}` |
| Filters | `\| filter` | `{{ name \| upper }}` |
| Pipeline | `\|> filter` | `{{ x \|> a \|> b }}` |
| Safe pipeline | `?\|> filter` | `{{ x ?\|> a ?\|> b }}` |
| Optional filter | `?\| filter` | `{{ x ?\| upper }}` |
| Nullish assign | `??=` | `{% let x ??= "default" %}` |

## Syntax Guide

:::{cards}
:columns: 2
:gap: medium

:::{card} Variables
:icon: variable
:link: /docs/syntax/variables/
:description: Output expressions and access patterns
`{{ name }}`, `{{ user.email }}`, `{{ items[0] }}`
:::{/card}

:::{card} Control Flow
:icon: git-branch
:link: /docs/syntax/control-flow/
:description: Conditionals, loops, and pattern matching
`{% if %}`, `{% for %}`, `{% match %}`
:::{/card}

:::{card} Filters
:icon: filter
:link: /docs/syntax/filters/
:description: Transform values in expressions
`{{ name | upper }}`, `{{ items | join(', ') }}`
:::{/card}

:::{card} Functions
:icon: function
:link: /docs/syntax/functions/
:description: Define reusable template functions and regions
`{% def %}`, `{% region %}`, `{% yield %}`, `{% call %}`
:::{/card}

:::{card} Inheritance
:icon: layers
:link: /docs/syntax/inheritance/
:description: Extend and override base templates
`{% extends %}`, `{% block %}`
:::{/card}

:::{card} Includes
:icon: file-plus
:link: /docs/syntax/includes/
:description: Include partials and components
`{% include %}`, context passing
:::{/card}

:::{card} Caching
:icon: database
:link: /docs/syntax/caching/
:description: Block-level output caching
`{% cache key %}...{% end %}`
:::{/card}

:::{card} Async
:icon: refresh-cw
:link: /docs/syntax/async/
:description: Async iteration and await
`async for`, `await`, async templates
:::{/card}

:::{/cards}

## Key Features

- **Unified `{% end %}`** — Clean, consistent block endings
- **Pattern matching** — `{% match status %}{% case "active" %}...{% end %}`
- **Pipeline operator** — `{{ title |> escape |> upper |> truncate(50) }}`
- **Safe pipeline** — `{{ user?.name ?|> upper ?? "Anonymous" }}` — None-propagating
- **Nullish assignment** — `{% let title ??= "Untitled" %}` — set only if undefined/None
- **Built-in caching** — `{% cache "sidebar" %}...{% end %}`
