-
-
Save brennandunn/7e0948d4456b93df9feefbcf1946d999 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{%- capture output -%} | |
{% assign salutations = "Hey< X>,/ Hi there<, X>,/ Hola< X>,/ What's going on<, X>?/ Hi< X>!" %} | |
{% assign salutations_array = salutations | split: '/' %} | |
{% assign salutations_length = salutations_array | size %} | |
{% assign random = "now" | date: "%9N" | modulo: salutations_length %} | |
{% assign template = salutations_array[random] %} | |
{% assign formatted_name = subscriber.first_name | split: " " | first | capitalize %} | |
{% if subscriber.first_name != "" %} | |
{% assign template = template | replace: "<", "" | replace: ">", "" %} | |
{% assign template = template | replace: "X", formatted_name %} | |
{% else %} | |
{% assign first_bit = template | split: "<" | first %} | |
{% assign last_bit = template | split: ">" | last %} | |
{% assign template = first_bit | append: last_bit %} | |
{% endif %} | |
{%- endcapture -%} | |
{{ template | strip_html | strip }} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
A tip for others – if you get the "Invalid Liquid" error from ConvertKit, try pressing "Raw" above and copying the plaintext code. That does the trick 👍