Launch offer for the first 500 accounts: $10K MTR free for 24 months + $100 credit →
    .io

    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

    OperatorMeaningExample
    ==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 %}
    containsString/array contains value{% if tags contains "premium" %}
    existsValue 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:

    ValueResult
    nil / null / undefinedFalsy
    falseFalsy
    "" (empty string)Falsy
    0Falsy
    Non-empty strings, non-zero numbers, objects, arraysTruthy

    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

    FilterArgumentsExampleOutput
    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
    truncatelength{{ title | truncate: 15 }}Premium Month...
    truncatewordscount{{ desc | truncatewords: 3 }}Unlock all features...
    appendstring{{ name | append: "!" }}John!
    prependstring{{ name | prepend: "Hi " }}Hi John
    replacesearch, replace{{ text | replace: "old", "new" }}—
    replace_firstsearch, replace{{ text | replace_first: "a", "b" }}—
    removesubstring{{ text | remove: "foo" }}—
    remove_firstsubstring{{ 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

    FilterArgumentsExampleOutput
    plusnumber{{ 5 | plus: 3 }}8
    minusnumber{{ 10 | minus: 4 }}6
    timesnumber{{ 9.99 | times: 0.8 }}7.992
    divided_bynumber{{ 100 | divided_by: 3 }}33.33…
    modulonumber{{ 10 | modulo: 3 }}1
    rounddecimals{{ 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
    currencysymbol (opt){{ 9.99 | currency }}$9.99
    percentagedecimals (opt){{ 0.856 | percentage: 1 }}85.6%
    at_leastmin{{ quantity | at_least: 1 }}≥ 1
    at_mostmax{{ quantity | at_most: 100 }}≤ 100

    Array Filters

    FilterArgumentsDescription
    first—Returns the first element
    last—Returns the last element
    joinseparatorJoins 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

    FilterArgumentsDescription
    dateformat string or presetFormats a date/timestamp
    date_addms-stringAdds a duration to a date
    date_subtractms-stringSubtracts a duration from a date
    countdown_fromstart, 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

    FilterArgumentsDescription
    defaultfallback valueReturns fallback if value is falsy
    default_if_nonefallback valueReturns 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:

    NotationMeaning
    10s10 seconds
    30m30 minutes
    2h2 hours
    1d1 day
    1w1 week
    1M1 month (30 days)
    1y1 year (365 days)
    {{ "now" | date_add: "7d" }}        → 7 days from now
    {{ trial_end | date_subtract: "2h" }} → 2 hours before trial ends

    Countdown 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.

    StyleExample (1d 2h 30m 15s)
    digital26:30:15
    digital_full01:02:30:15
    long1 day, 2 hours, 30 minutes, 15 seconds
    short1d 2h 30m 15s
    narrow1d 2h 30m 15s
    wide1 day, 2 hours, 30 minutes, 15 seconds
    compact1:02:30:15
    columnSeparate spans for days / hours / minutes / seconds
    long_most_significant1 day
    short_most_significant1d
    narrow_most_significant1d
    wide_most_significant1 day
    days_only1 day
    hours_only26 hours
    minutes_only1590 minutes
    seconds_only95415 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

    TokenMeaningExample
    %Y4-digit year2026
    %y2-digit year26
    %mZero-padded month02
    %dZero-padded day22
    %H24-hour hour14
    %I12-hour hour02
    %MMinutes30
    %SSeconds45
    %pAM/PMPM
    %BFull month nameFebruary
    %bAbbreviated monthFeb
    %AFull day nameSunday
    %aAbbreviated daySun
    %ZTimezone nameUTC

    Preset Formats

    PresetExample Output
    iso2026-02-22T14:30:00
    date2026-02-22
    time14:30:00
    datetime2026-02-22 14:30:00
    short02/22/2026
    longFebruary 22, 2026
    fullSunday, February 22, 2026
    time1202:30 PM
    time2414:30
    {{ trial_end | date: "long" }}       → February 22, 2026
    {{ trial_end | date: "%B %d" }}     → February 22
    {{ "now" | date: "time12" }}        → 02:30 PM

    Complete 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:

    We use cookies and process your data to provide our services. By continuing, you agree to our Terms and Privacy Policy.