generate_summary@v1.prompt
generateText({ prompt: 'generate_summary@v1', variables: { max_paragraphs: 2, company_data: '...' } }), Liquid replaces {{ max_paragraphs }} with 2 and {{ company_data }} with your content before the prompt is sent to the LLM.
Templates render before YAML parsing, so you can template the frontmatter too — useful for dynamic model selection or configuration.
Variables
The double-brace syntax{{ variableName }} renders values from the variables object you pass to the generate function.
Conditionals
Use{% if %} to include content only when a condition is true:
include_competitors: true, the competitor instruction is included. With false or undefined, it’s omitted entirely.
Add {% else %} for alternate content:
{% unless %} for the inverse — it renders when the condition is falsy:
Loops
Iterate over arrays with{% for %}:
forloop.index gives you the 1-based position (1, 2, 3…). Use forloop.index0 for 0-based indexing.
For arrays of objects:
Filters
Filters transform values using the pipe syntax{{ value | filter }}.
Text transformations:
tone is undefined or empty, it renders as “professional”.
Chaining filters:
Templating Frontmatter
Variables work in the YAML frontmatter too. This lets you dynamically configure model settings:Common Patterns
Optional sections based on input:Cheatsheet
Quick reference for the most common Liquid.js syntax.Output
| Syntax | Description | Example |
|---|---|---|
{{ variable }} | Output a variable | {{ name }} → Acme Corp |
{{ obj.property }} | Dot notation | {{ company.industry }} → SaaS |
{{ array[0] }} | Array index | {{ items[0] }} → first item |
Tags
| Syntax | Description |
|---|---|
{% if condition %}...{% endif %} | Conditional block |
{% if condition %}...{% else %}...{% endif %} | If/else |
{% elsif condition %} | Else if |
{% unless condition %}...{% endunless %} | Negative conditional |
{% for item in array %}...{% endfor %} | Loop over array |
{% assign var = value %} | Create a variable |
{% capture var %}...{% endcapture %} | Capture block into variable |
{% comment %}...{% endcomment %} | Comment (not rendered) |
Operators
| Operator | Description | Example |
|---|---|---|
== | Equals | {% if status == "active" %} |
!= | Not equals | {% if type != "draft" %} |
>, <, >=, <= | Comparison | {% if count > 0 %} |
and | Logical and | {% if a and b %} |
or | Logical or | {% if a or b %} |
contains | String/array contains | {% if tags contains "saas" %} |
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 |
String Filters
| Filter | Example | Result |
|---|---|---|
upcase | {{ "hello" | upcase }} | HELLO |
downcase | {{ "HELLO" | downcase }} | hello |
capitalize | {{ "hello world" | capitalize }} | Hello world |
strip | {{ " hi " | strip }} | hi |
truncate: n | {{ "hello world" | truncate: 5 }} | he... |
truncatewords: n | {{ "one two three" | truncatewords: 2 }} | one two... |
replace: a, b | {{ "hello" | replace: "l", "x" }} | hexxo |
remove: str | {{ "hello" | remove: "l" }} | heo |
append: str | {{ "hello" | append: "!" }} | hello! |
prepend: str | {{ "world" | prepend: "hello " }} | hello world |
split: delim | {{ "a,b,c" | split: "," }} | ["a","b","c"] |
Array Filters
| Filter | Example | Result |
|---|---|---|
join: delim | {{ arr | join: ", " }} | a, b, c |
first | {{ arr | first }} | First element |
last | {{ arr | last }} | Last element |
size | {{ arr | size }} | Array length |
reverse | {{ arr | reverse }} | Reversed array |
sort | {{ arr | sort }} | Sorted array |
uniq | {{ arr | uniq }} | Unique elements |
map: prop | {{ users | map: "name" }} | Array of names |
where: prop, val | {{ users | where: "active", true }} | Filtered array |
Other Filters
| Filter | Example | Result |
|---|---|---|
default: val | {{ x | default: "none" }} | none if x is nil/empty |
date: format | {{ now | date: "%Y-%m-%d" }} | 2024-01-15 |
json | {{ obj | json }} | JSON string |
escape | {{ html | escape }} | HTML-escaped string |
newline_to_br | {{ text | newline_to_br }} | \n → <br> |
Number Filters
| Filter | Example | Result |
|---|---|---|
plus: n | {{ 5 | plus: 3 }} | 8 |
minus: n | {{ 5 | minus: 3 }} | 2 |
times: n | {{ 5 | times: 3 }} | 15 |
divided_by: n | {{ 10 | divided_by: 3 }} | 3 |
modulo: n | {{ 10 | modulo: 3 }} | 1 |
round | {{ 4.6 | round }} | 5 |
ceil | {{ 4.2 | ceil }} | 5 |
floor | {{ 4.8 | floor }} | 4 |