xFlow Templating Reference
What is xFlow?
xFlow is BillDog's templating language for dynamic paywall content. It lets you inject computed values, conditional blocks, and formatted data directly into text, images, and component properties — all resolved at render time on every platform.
xFlow uses two delimiter types:
{% %}— Control flow (assign, if/elsif/else, unless, case/when){{ }}— Output / interpolation (variables, filters, expressions)
Execution order: {% %} tags run first as a preprocessing pass, then {{ }} interpolation resolves all remaining placeholders. See the Variable System Reference for the full resolution priority chain.
The user.* in these examples is not the signed-in user. They are custom variables you pass in when rendering. A BillDog Auth session and its entitlements are not available to xFlow templates — gate on the token in your own code instead. See BillDog Auth for the user-versus-customer distinction.
Control Flow Tags
assign
Create or overwrite a variable. Supports filter chaining.
{% assign discounted = selectedProduct.rawPrice | times: 0.8 | round: 2 %}
{% assign greeting = "Hello " | append: userName | upcase %}if / elsif / else / endif
Conditionally include content. Nesting is supported.
{% if isVip %}
Welcome back, VIP!
{% elsif selectedProduct.hasFreeTrial %}
Start your free trial today
{% else %}
Upgrade to unlock everything
{% endif %}Conditions use the operators and truthiness rules documented below. Logical operators (and, or) are evaluated left-to-right with no precedence — use nesting for complex logic. A condition may be negated with a leading! — e.g. {% if !isVip %} or{% if !(a and b) %}.
unless / endunless
The inverse of {% if %} — renders its body when the condition isfalsy. elsif / else are supported, andendif / endunless are interchangeable terminators.
{% unless isVip %}
Upgrade to unlock everything
{% endunless %}case / when / else / endcase
Matches one expression against several values. The expression is evaluated once; the first {% when %} whose value matches emits its body, falling back to {% else %}. A when may list comma-separated values. Nesting is supported.
{% case user.plan %}
{% when "pro" %}
Pro member
{% when "enterprise", "team" %}
Enterprise member
{% else %}
Free member
{% endcase %}Operators & Truthiness
Comparison Operators
| Operator | Meaning | Example |
|---|---|---|
== | Equal | {% if plan == "pro" %} |
!= | Not equal | {% if status != "expired" %} |
> | Greater than | {% if credits > 0 %} |
< | Less than | {% if daysLeft < 3 %} |
>= | Greater or equal | {% if score >= 80 %} |
<= | Less or equal | {% if attempts <= 3 %} |
contains | String/array contains value | {% if tags contains "premium" %} |
exists | Value is set (not nil, not empty) | {% if email exists %} |
To test whether a variable is set, use exists (or a bare{% if email %} truthiness check). An unset variable isnil — it does not equal the string "nil", so{% if x == "nil" %} is not a valid "is-unset" test.
Logical Operators
and / or combine conditions. They evaluate left-to-right with no operator precedence (no short-circuit grouping). Use nested {% if %} blocks for complex logic.
{% if isVip and credits > 0 %}
{% if plan == "pro" or plan == "enterprise" %}Truthiness Rules
The following values are falsy; everything else is truthy:
| Value | Result |
|---|---|
nil / null / undefined | Falsy |
false | Falsy |
"" (empty string) | Falsy |
0 | Falsy |
| Non-empty strings, non-zero numbers, objects, arrays | Truthy |
Filters
Filters transform values using the pipe (|) syntax. They work in both{{ }} output tags and {% assign %} tags.
{{ userName | upcase }}
{{ selectedProduct.rawPrice | times: 0.8 | currency }}
{% assign label = title | truncate: 20 | append: "..." %}String Filters
| Filter | Arguments | Example | Output |
|---|---|---|---|
upcase | — | {{ "hello" | upcase }} | HELLO |
downcase | — | {{ "HELLO" | downcase }} | hello |
capitalize | — | {{ "hello world" | capitalize }} | Hello world |
titlecase | — | {{ "hello world" | titlecase }} | Hello World |
strip | — | {{ " hi " | strip }} | hi |
lstrip | — | {{ " hi" | lstrip }} | hi |
rstrip | — | {{ "hi " | rstrip }} | hi |
truncate | length | {{ title | truncate: 15 }} | Premium Month... |
truncatewords | count | {{ desc | truncatewords: 3 }} | Unlock all features... |
append | string | {{ name | append: "!" }} | John! |
prepend | string | {{ name | prepend: "Hi " }} | Hi John |
replace | search, replace | {{ text | replace: "old", "new" }} | — |
replace_first | search, replace | {{ text | replace_first: "a", "b" }} | — |
remove | substring | {{ text | remove: "foo" }} | — |
remove_first | substring | {{ text | remove_first: "foo" }} | — |
size | — | {{ "hello" | size }} | 5 |
escape | — | {{ html | escape }} | HTML-escaped |
url_encode | — | {{ path | url_encode }} | URL-encoded |
url_decode | — | {{ encoded | url_decode }} | URL-decoded |
Number Filters
| Filter | Arguments | Example | Output |
|---|---|---|---|
plus | number | {{ 5 | plus: 3 }} | 8 |
minus | number | {{ 10 | minus: 4 }} | 6 |
times | number | {{ 9.99 | times: 0.8 }} | 7.992 |
divided_by | number | {{ 100 | divided_by: 3 }} | 33.33… |
modulo | number | {{ 10 | modulo: 3 }} | 1 |
round | decimals | {{ 7.992 | round: 2 }} | 7.99 |
floor | — | {{ 7.8 | floor }} | 7 |
ceil | — | {{ 7.2 | ceil }} | 8 |
abs | — | {{ -5 | abs }} | 5 |
number_with_delimiter | — | {{ 1234567 | number_with_delimiter }} | 1,234,567 |
currency | symbol (opt) | {{ 9.99 | currency }} | $9.99 |
percentage | decimals (opt) | {{ 0.856 | percentage: 1 }} | 85.6% |
at_least | min | {{ quantity | at_least: 1 }} | ≥ 1 |
at_most | max | {{ quantity | at_most: 100 }} | ≤ 100 |
Array Filters
| Filter | Arguments | Description |
|---|---|---|
first | — | Returns the first element |
last | — | Returns the last element |
join | separator | Joins elements into a string |
reverse | — | Reverses the array order |
sort | — | Sorts elements by their stringified value (arguments are ignored) |
uniq | — | Removes duplicate values |
compact | — | Removes nil/null values |
{{ features | join: ", " }}
{{ tags | sort | first }}Date & Time Filters
| Filter | Arguments | Description |
|---|---|---|
date | format string or preset | Formats a date/timestamp |
date_add | ms-string | Adds a duration to a date |
date_subtract | ms-string | Subtracts a duration from a date |
countdown_from | start, style, max_unit (opt) | Formats remaining time until a future date |
countdown_days_total | — | Total remaining days as integer |
countdown_hours_total | — | Total remaining hours as integer |
countdown_minutes_total | — | Total remaining minutes as integer |
countdown_seconds_total | — | Total remaining seconds as integer |
to_ordinal | — | Day of month with suffix (1st, 2nd, 3rd…) |
to_month_name | — | Full month name (January, February…) |
to_day_name | — | Full day name (Monday, Tuesday…) |
relative_time | — | Human-readable relative time ("in 3 days") |
{{ trial_end | date: "%B %d, %Y" }}
{{ "now" | date_add: "7d" | date: "long" }}
{{ offer_expires | countdown_from: "now", "digital", "hours" }}Utility Filters
| Filter | Arguments | Description |
|---|---|---|
default | fallback value | Returns fallback if value is falsy |
default_if_none | fallback value | Returns fallback only if value is nil/null |
{{ userName | default: "Friend" }}
{{ promo_code | default_if_none: "WELCOME" }}Filter Chaining
Multiple filters are applied left-to-right using the pipe (|) operator. The output of each filter becomes the input of the next.
{{ selectedProduct.rawPrice | times: 0.8 | round: 2 | currency }}
→ $7.99
{% assign headline = userName | default: "there" | prepend: "Hey, " | append: "!" %}
→ Hey, John!ms-string Shorthand
Duration values used with date_add and date_subtract are expressed in a compact notation:
| Notation | Meaning |
|---|---|
10s | 10 seconds |
30m | 30 minutes |
2h | 2 hours |
1d | 1 day |
1w | 1 week |
1M | 1 month (30 days) |
1y | 1 year (365 days) |
{{ "now" | date_add: "7d" }} → 7 days from now
{{ trial_end | date_subtract: "2h" }} → 2 hours before trial endsCountdown Formats
The countdown_from filter formats the time between the piped end date and a start date. Arguments are positional: the first is the start date (pass"now" for the current time), the second is the style that controls how the remaining time is formatted, and an optional third max_unit caps the largest unit displayed. There is no keyword-argument syntax.
| Style | Example (1d 2h 30m 15s) |
|---|---|
digital | 26:30:15 |
digital_full | 01:02:30:15 |
long | 1 day, 2 hours, 30 minutes, 15 seconds |
short | 1d 2h 30m 15s |
narrow | 1d 2h 30m 15s |
wide | 1 day, 2 hours, 30 minutes, 15 seconds |
compact | 1:02:30:15 |
column | Separate spans for days / hours / minutes / seconds |
long_most_significant | 1 day |
short_most_significant | 1d |
narrow_most_significant | 1d |
wide_most_significant | 1 day |
days_only | 1 day |
hours_only | 26 hours |
minutes_only | 1590 minutes |
seconds_only | 95415 seconds |
{{ offer_expires | countdown_from: "now", "digital" }}
{{ offer_expires | countdown_from: "now", "long", "hours" }}
{{ offer_expires | countdown_from: "now", "column" }}Date Format Tokens
The date filter accepts either a strftime-style format string or a preset name.
Strftime Tokens
| Token | Meaning | Example |
|---|---|---|
%Y | 4-digit year | 2026 |
%y | 2-digit year | 26 |
%m | Zero-padded month | 02 |
%d | Zero-padded day | 22 |
%H | 24-hour hour | 14 |
%I | 12-hour hour | 02 |
%M | Minutes | 30 |
%S | Seconds | 45 |
%p | AM/PM | PM |
%B | Full month name | February |
%b | Abbreviated month | Feb |
%A | Full day name | Sunday |
%a | Abbreviated day | Sun |
%Z | Timezone name | UTC |
Preset Formats
| Preset | Example Output |
|---|---|
iso | 2026-02-22T14:30:00 |
date | 2026-02-22 |
time | 14:30:00 |
datetime | 2026-02-22 14:30:00 |
short | 02/22/2026 |
long | February 22, 2026 |
full | Sunday, February 22, 2026 |
time12 | 02:30 PM |
time24 | 14:30 |
{{ trial_end | date: "long" }} → February 22, 2026
{{ trial_end | date: "%B %d" }} → February 22
{{ "now" | date: "time12" }} → 02:30 PMComplete Example
A realistic paywall text block combining multiple xFlow features:
{% assign savings = selectedProduct.rawPrice | times: 0.2 | round: 2 | currency %}
{% assign trial_deadline = "now" | date_add: "7d" %}
{% if isVip %}
Welcome back, {{ userName | default: "friend" | capitalize }}!
{% elsif selectedProduct.hasFreeTrial %}
Start your free trial — offer ends {{ trial_deadline | date: "long" }}
({{ trial_deadline | countdown_from: "now", "compact" }} left)
{% else %}
Save {{ savings }} today — upgrade to {{ selectedProduct.title }}
for just {{ selectedProduct.rawPrice | times: 0.8 | round: 2 | currency }}/{{ selectedProduct.period }}
{% endif %}Was this page helpful?
Or rate this page: