Sheet to PDF
Help · Advanced features · Smart templates

Smart templates — if/else, filters, loops, math

On paid plans, your Google Doc templates can contain conditional logic, formatting filters, loops, and math — built on top of the popular Liquid syntax.

Contents

Why smart templates?

Without smart templates, every variation in your data needs a different template. Smart templates let one template handle all the variations — VAT shown only when applicable, content adapted by seniority level, loops over a JSON array of line items.

Conditional blocks (if / else)

Single line

{% if VAT > 0 %}VAT: {{ VAT | currency:"EUR" }}{% endif %}

If VAT is 0 or empty, the entire line is removed.

Multiple lines

{% if HasDiscount %}
Discount: -{{ Discount | currency:"EUR" }}
Reason: {{ DiscountReason | default:"Promo" }}
{% endif %}

If / else

{% if Status == "paid" %}
Thank you for your payment.
{% else %}
Please pay by {{ DueDate | date:"MMMM dd, yyyy" }}.
{% endif %}

Comparison operators

Filters (formatting + defaults)

Available on all paid plans. Pipe a value through a filter with |:

FilterExampleOutput
default{{ Name | default:"Customer" }}"Customer" if empty
currency{{ Amount | currency:"EUR" }}1,250.00 EUR
date{{ Date | date:"MMMM dd, yyyy" }}May 30, 2026
upper{{ x | upper }}FRANCE
lower{{ x | lower }}france
capitalize{{ x | capitalize }}France
truncate{{ Bio | truncate:50 }}First 50 chars + …

Filter chaining

Combine multiple filters with successive pipes:

{{ Name | default:"unknown" | upper }}    → UNKNOWN

Loops (Pro+ only)

When a sheet column contains a JSON array, iterate over each item with {% for %}:

{% for item in Items %}
- {{ item.name }}: {{ item.price | currency:"EUR" }}
{% endfor %}

The Items column in your sheet should contain valid JSON, like:

[{"name":"Apple","price":1.50},{"name":"Bread","price":3.00}]

Math operations (Pro+ only)

Subtotal: {{ Amount | currency:"EUR" }}
Tax (20%): {{ Amount * 0.20 | currency:"EUR" }}
Total: {{ Amount * 1.20 | currency:"EUR" }}

Supported: +, -, *, /. Math happens before filters, so always pipe to currency at the end.

Common recipes

Optional VAT line

Subtotal: {{ Subtotal | currency:"EUR" }}
{% if VAT > 0 %}VAT ({{ VATRate }}%): {{ VAT | currency:"EUR" }}
{% endif %}Total: {{ Total | currency:"EUR" }}

Adapt to seniority

Dear {{ Candidate }},

{% if Seniority == "senior" %}
We're delighted to extend a senior offer including equity grants.
{% else %}
We're delighted to extend an offer with a competitive starting package.
{% endif %}

Multi-item invoice

{% for item in Items %}
{{ item.name }}                {{ item.price | currency:"EUR" }}
{% endfor %}
─────────────────────────────────
Total: {{ Subtotal | currency:"EUR" }}

Pitfalls to avoid