🗒️ Navigation to snippets

Content Segmentation based on Contact Affinity

{% if contact.affinity == 'private' %}
<p>This is Private Content</p>
{% endif %} 
{% if contact.affinity == 'b2b' %}
<p>This is B2B Content</p>
{% endif %} 
{% if contact.affinity == 'agency' %}
<p>This is Agency Content</p>
{% endif %}

Get the content from an external URL address and process it

Json decode is optional

{% set content = '<https://your.url>' | get_content_from_url | json_decode %}
{{ content.title }}
{{ content.data }}
{{ content.link}}

Fetch RSS data

{% set feed= '<https://your.rss.feed.url>' | rss %}

<h1>{{ feed.channel.title }}</h1>
<p><a href="{{ feed.channel.link }}">{{ feed.channel.link }}</a></p>
<p>Published: {{ feed.channel.pubDate }}</p>
<p>{{ feed.channel.description }}</p>

<h2>Articles</h2>
<ul>
    {% for item in feed.channel.item %}
        <li>
            <h3><a href="{{ item.link }}">{{ item.title }}</a></h3>
            <p>Published: {{ item.pubDate }}</p>
            <div>{{ item.description|raw }}</div>
        </li>
    {% endfor %}
</ul>

Always capitalize

{{ contact.firstname|capitalize }}

Time-based greetings

{% set currentTime = "now"|date("H") %}
{% if currentTime >= 5 and currentTime < 12 %}
    <p>Good morning!</p>
{% elseif currentTime >= 12 and currentTime < 18 %}
    <p>Good afternoon!</p>
{% else %}
    <p>Good evening!</p>
{% endif %}

Expiry date

{% set dateExpiry = contact.date_last_order |date('d-m-Y') %}
{% set today = "now"|date('d-m-Y') %}
{% set difference = date(today).diff(date(dateExpiry))%}
{% set leftDays = difference.days %}
{% if dateExpiry == today %}
      1 day
{% else %}
    {{ leftDays }} days left
{% endif %}

Date magic

Tomorrow
{{ "now"|date_modify('+1 day')|date("m/d/Y") }}

Today
{{ "now"|date("m/d/Y") }}

Today is happy {{ "now"|date("l") }}

Fallback