Basic Syntax
Variable Output
Use double curly braces to output values:Filters
Apply filters to transform values:Tags
Use tags for logic and control flow:Accessing Input Values
All input fields are available underinputs:
Default Values
Use thedefault filter for optional fields:
Common Filters
String Filters
| Filter | Description | Example |
|---|---|---|
upcase | Convert to uppercase | {{ "hello" | upcase }} → HELLO |
downcase | Convert to lowercase | {{ "HELLO" | downcase }} → hello |
capitalize | Capitalize first letter | {{ "hello" | capitalize }} → Hello |
truncate | Shorten with ellipsis | {{ "hello world" | truncate: 8 }} → hello... |
strip | Remove whitespace | {{ " hello " | strip }} → hello |
replace | Replace text | {{ "hello" | replace: "e", "a" }} → hallo |
split | Split into array | {{ "a,b,c" | split: "," }} → array |
Number Filters
| Filter | Description | Example |
|---|---|---|
plus | Add numbers | {{ 5 | plus: 3 }} → 8 |
minus | Subtract | {{ 5 | minus: 3 }} → 2 |
times | Multiply | {{ 5 | times: 3 }} → 15 |
divided_by | Divide | {{ 10 | divided_by: 2 }} → 5 |
round | Round number | {{ 4.6 | round }} → 5 |
Array Filters
| Filter | Description | Example |
|---|---|---|
size | Array length | {{ inputs.items | size }} |
first | First element | {{ inputs.items | first }} |
last | Last element | {{ inputs.items | last }} |
join | Join with separator | {{ inputs.items | join: ", " }} |
sort | Sort array | {{ inputs.items | sort }} |
reverse | Reverse order | {{ inputs.items | reverse }} |
uniq | Remove duplicates | {{ inputs.items | uniq }} |
Control Flow
If / Else
Unless
Case / When
Loops
For Loop
Loop Variables
| Variable | Description |
|---|---|
forloop.index | Current iteration (1-based) |
forloop.index0 | Current iteration (0-based) |
forloop.first | True if first iteration |
forloop.last | True if last iteration |
forloop.length | Total iterations |
Loop Example with Conditions
Working with Objects
Access nested properties with dot notation:Iterate Over Object Properties
Including Snippets
Reuse common template fragments with includes:Snippets are defined in the Prompt Snippets section. See Working with Snippets for details.
Real-World Examples
Email Generator
Content Classifier
Multi-Language Support
Best Practices
Always use defaults
Always use defaults
Optional fields should have sensible defaults to prevent empty values in prompts.
Truncate long inputs
Truncate long inputs
Use
truncate to prevent extremely long inputs from exceeding token limits.Use includes for reusability
Use includes for reusability
Common instructions (JSON formatting, tone guidelines) should be snippets.
Test edge cases
Test edge cases
Test with empty arrays, missing optional fields, and unusual values.
Keep logic simple
Keep logic simple
Complex logic is hard to debug. Keep conditionals straightforward.
Debugging Templates
If your template isn’t working:- Check the rendered preview in the prompt editor
- Verify input field names match exactly
- Test with simple values first
- Check for typos in filter names
- Ensure conditionals have proper
endif/endfortags

