Skip to content

template

The template section defines what text gets inserted when you submit the form. It uses the Liquid template language to transform your form data into formatted output.

Every field from your schema becomes a variable you can use in the template.

Required Section

Every form config must include a template. This is the output of your form.

Basic Structure

Use {{fieldName}} to insert field values:

yml
template: |
  Subject: {{subject}}
  Priority: {{priority}}
  
  Hi {{contact_name}},
  
  Just following up on our conversation about {{subject}}.

The | after template: enables multi-line text. Each line becomes part of your output.

Using Filters

Filters transform values before inserting them. Apply filters with the pipe symbol |:

yml
template: |
  Name: {{name | capitalize}}
  Priority: {{priority | upcase}}
  Word count: {{content | split: ' ' | size}}

Common filters:

FilterWhat It DoesExample
upcaseUPPERCASE{{text | upcase}}HELLO
downcaselowercase{{text | downcase}}hello
capitalizeFirst letter uppercase{{text | capitalize}}Hello
stripRemove leading/trailing whitespace{{text | strip}}
sizeCount characters or array items{{text | size}}5
defaultFallback if empty{{name | default: 'Anonymous'}}

See all filters here: https://liquidjs.com/filters/overview.html

template-demo.avifForm config on the left, anime girl in the middle, and generated output on the right

Conditionals

Show content only when conditions are met:

yml
template: |
  Subject: {{subject}}
  {% if priority == 'High' %}
  ⚠️ URGENT: Please review immediately
  {% endif %}
  
  {% if notes != blank %}
  Notes:
  {{notes}}
  {% endif %}

Use blank to check for empty strings. Use nil to check for missing values.

Loops

Iterate over arrays:

yml
template: |
  Selected items:
  {% for item in selections %}
  - {{item}}
  {% endfor %}

Special Variables

Beyond your form fields, you can access:

VariableDescription
{{clipboard}}System clipboard content at form load
{{env.VARIABLE_NAME}}Environment variables
{{newline}}A newline character (\n)
{{tab}}A tab character (\t)
yml
template: |
  User: {{env.USERNAME}}
  Original text: {{clipboard}}
  Your response: {{response}}
  
  Items:{{newline}}{{items | join: newline}}

Best Practices

PracticeWhyExample
Check for blank before renderingPrevents empty sections{% if notes != blank %}
Use size > 0 for arraysEnsures array has items{% if items.size > 0 %}
Use default filterProvides fallback values{{name | default: 'N/A'}}
Use strip on user inputRemoves accidental whitespace{{input | strip}}

Learn More