Skip to content

Module 22: Quick Reference Card

Block Syntax Purpose
{% raw %} Output {{ value }}
{% raw %} Filter {{ value | filter }}
{% raw %} Tag {% tag %}

Type Example Key Rule
String "Hello", "95000" CRM fields arrive as strings
Number 72, 1.15 Must convert from string before math
Boolean true, false Snippets return strings, not booleans
Array ["a","b","c"] Created with split, not typed directly
Nil / Empty nil, "" Use default to catch both

{% raw %}
{%- # String → Number (integer) -%}
{% assign n = some_field | default: 0 | plus: 0 %}
{%- # String → Number (decimal) -%}
{% assign n = some_field | default: 0 | times: 1.0 %}
{%- # String → Array -%}
{% assign items = some_field | split: "," %}
{%- # Array → String -%}
{{ items | join: ", " }}
{%- # Nil/Empty → Fallback -%}
{{ some_field | default: "fallback" }}
{% endraw %}

Filter Example Result
upcase "acme" | upcase ACME
downcase "ACME" | downcase acme
capitalize "acme corp" | capitalize Acme corp
strip " hi " | strip hi
replace: "a","b" "cat" | replace: "c","b" bat
remove: "x" "extra" | remove: "x" etra
append: "!" "hello" | append: "!" hello!
prepend: "$" "100" | prepend: "$" $100
truncate: n "hello world" | truncate: 8 hello...
truncatewords: n "one two three" | truncatewords: 2 one two...
size "hello" | size 5
split: "," "a,b,c" | split: "," ["a","b","c"]
default: "x" nil | default: "N/A" N/A

Filter Example Result
plus: n 10 | plus: 5 15
minus: n 100 | minus: 25 75
times: n 5 | times: 3 15
divided_by: n 100 | divided_by: 4 25
divided_by: n.0 100 | divided_by: 3.0 33.33
modulo: n 10 | modulo: 3 1
round: n 4.678 | round: 2 4.68
floor 4.9 | floor 4
ceil 4.1 | ceil 5
abs -5 | abs 5

⚠️ divided_by with an integer divisor = integer division (truncates). Use .0 for decimal results.


Filter Example Result
join: ", " ["a","b"] | join: ", " a, b
first ["a","b","c"] | first a
last ["a","b","c"] | last c
size ["a","b","c"] | size 3
sort ["c","a","b"] | sort ["a","b","c"]
uniq ["a","a","b"] | uniq ["a","b"]
reverse ["a","b","c"] | reverse ["c","b","a"]

Code Meaning Output
%B Full month January
%b Short month Jan
%d Day (01–31) 15
%e Day (1–31) 5
%Y 4-digit year 2026
%A Full weekday Monday
%H:%M 24-hour time 14:30
%s Unix timestamp 1736899200

Common patterns:

{% raw %}
{{ date | date: "%B %d, %Y" }} → January 15, 2026
{{ date | date: "%b %e, %Y" }} → Jan 5, 2026
{{ date | date: "%m/%d/%Y" }} → 01/15/2026
{{ "now" | date: "%B %Y" }} → March 2026
{% endraw %}

Filter Purpose Affects Screen? Affects Audio?
cast_titlecase Proper company name casing
cast_apostrophe Smart possessive ('s or ')
cast_pronounce Audio pronunciation control
cast_highlight Visual text emphasis
cast_footnote Silent reference notes

cast_pronounce patterns:

Pattern Usage Narrator Says
(basic) "CSM" | cast_pronounce Dictionary lookup
"number_pair" "346780" | cast_pronounce: "number_pair" 34 67 80
"by_char" "CSM123" | cast_pronounce: "by_char" C S M 1 2 3
"version" "1.2.3" | cast_pronounce: "version" 1 point 2 point 3
"all" text | cast_pronounce: "all" All dictionary matches

if / elsif / else:

{% raw %}
Excellent.
{% elsif score >= 60 %}
Good.
{% else %}
Needs work.
{% endraw %}

unless:

{% raw %}
{% unless renewal_date == blank %}
Renews on {{ renewal_date | date: "%B %d, %Y" }}.
{% endunless %}
{% endraw %}

case / when:

{% raw %}
{% case tier %}
{% when "Enterprise" %}
All features.
{% when "Professional" %}
Core features.
{% else %}
Contact CSM.
{% endcase %}
{% endraw %}

for loop:

{% raw %}
{% for item in array limit: 3 %}
{{ forloop.index }}. {{ item | strip }}
{% endfor %}
{% endraw %}

Loop variables: forloop.index (1-based), forloop.index0 (0-based), forloop.first, forloop.last, forloop.length


Operator Meaning
== Equals
!= Not equal
> < >= <= Numeric comparison
contains String/array contains value (case-sensitive)
and Both conditions must be true
or Either condition can be true
blank Tests for nil or empty string

{% raw %}
{%- # assign — single value -%}
{% assign name = contact_first_name | default: "there" %}
{%- # capture — complex text -%}
{% capture msg %}Hi {{ name }}, welcome!{% endcapture %}
{% endraw %}

{% raw %}
{%- tag -%} strips whitespace on both sides
{{- value -}} strips whitespace on both sides
{% endraw %}

{% raw %}
{% comment %} Block comment — multi-line {% endcomment %}
{%- # Inline comment — single line -%}
{% endraw %}

  1. Snippets always return strings — never booleans or numbers {% raw %}2. Compare with == against quoted strings: &#123;% if IsEMEA == "yes" %&#125;{% endraw %} {% raw %}3. Always | strip before comparing: &#123;%- assign r = IsEMEA | strip -%&#125;{% endraw %}
  2. Design with “yes”/“no” — not “true”/“false” {% raw %}5. Convert numeric output: &#123;%- assign n = MySnippet | strip | plus: 0 -%&#125;{% endraw %}

{% raw %}
{% comment %}
[Narration name and purpose]
[Data sources / Snippets used]
[Updated: date]
{% endcomment %}
{%- assign name = contact_first_name | default: "there" -%}
{%- assign company = contact_account_name | default: "your company" | cast_titlecase -%}
{%- assign score = health_score | default: 0 | plus: 0 -%}
{%- assign arr_val = arr | default: 0 | plus: 0 -%}
{%- assign renewal = renewal_date | default: "" -%}
{%- assign region = IsEMEA | default: "" | strip -%}
{% endraw %}

Safe greeting:

{% raw %}
Hi {{ contact_first_name | default: "there" }},
{% endraw %}

Company possessive:

{% raw %}
{{ contact_account_name | default: "your company" | cast_titlecase | cast_apostrophe }}
{% endraw %}

Numeric comparison:

{% raw %}
{%- assign score = health_score | default: 0 | plus: 0 -%}
{% endraw %}

Percentage calculation:

{% raw %}
{%- assign pct = used | divided_by: total | times: 100 | round: 0 -%}
{% endraw %}

⚠️ Ensure total is decimal (times: 1.0) and > 0.

Snippet boolean:

{% raw %}
{%- assign region = IsEMEA | strip -%}
{% endraw %}

Top N from list:

{% raw %}
{%- assign items = list | split: "," -%}
{% for item in items limit: 3 %}
{{ forloop.index }}. {{ item | strip }}
{% endfor %}
{% endraw %}

Pluralization:

{% raw %}
{{ count }} item{%- if count != "1" %}s
{% endraw %}

Days until date:

{% raw %}
{%- assign target_ts = target_date | date: "%s" | plus: 0 -%}
{%- assign now_ts = "now" | date: "%s" | plus: 0 -%}
{%- assign days = target_ts | minus: now_ts | divided_by: 86400 -%}
{% endraw %}

Benchmark month:

{% raw %}
{{ "now" | date: "%B %Y" }} → March 2026
{% endraw %}

{% raw %}
DEBUG: [{{ MyVar }}] len={{ MyVar | size }}
DEBUG: numeric={{ MyVar | plus: 0 }}
{% endraw %}

Remove before publishing.


Topic URL
Overview https://school.cast.app/liquid.html
Tags/Blocks https://school.cast.app/liquid/liquid-blocks.html
Standard Filters https://school.cast.app/liquid/liquid-filters.html
Custom Cast Filters https://school.cast.app/liquid/custom-cast-filters.html
Snippet Library https://school.cast.app/liquid/liquid-library.html
Contact Variables https://school.cast.app/fields-snippets-data-validation/contact-variables.html
Pronunciations https://school.cast.app/personalizing-content/pronunciations.html

Congratulations — you’ve completed all 22 modules of Learn Cast Liquid. You can now:

  • Write output tags, apply filters, and use logic to create adaptive narrations
  • Handle every data type and convert between them safely
  • Use all five Cast custom filters for professional, polished presentations
  • Build production-quality snippets with proper string handling
  • Troubleshoot and debug common errors
  • Chain everything together into complete, personalized Cast experiences

Keep this Quick Reference Card handy, and refer back to the individual modules when you need a deeper explanation.

Happy templating!