🥸Mustache

Our templating system supports {{mustache}}. It allows us to use variables to create dynamic content. For instance, instead of sending an email with a classic "Dear client," headline, we can use "Dear {{firstname}},".

<p>Dear {{firstname}},</p> <!-- Input -->
<p>Dear Corentin,</p> <!-- Output if my user.firstname == Corentin -->
<p>Dear ,</p> <!-- Output if my user.firstname doesn't exist or is empty. -->

Variables can be used at the participation-level (poke), rewards included. Here are a few examples of variables (the whole list can be retrieved below):

  • {{firstname}}, {{lastname}}, {{email}}

  • {{poke_data.X}} (for instance, if the "card_fid" info is stored in poke_data, calling {{poke_data.card_fid}} will return the value)

  • {{reward_name}}, {{reward_description}}, {{reward_image}}, {{reward_custom_data.X}}

  • {{bonus_name}}, {{bonus_description}}, {{bonus_image}}, {{bonus_custom_data.X}}

Advanced

Mustache can also render arrays of items. For instance, calling {{pool_id_rewards}} will return an array of every rewards linked to a participation:

<p>{{pool_id_rewards}}</p> <!-- Input -->
<p>[{{item1}},{{item2}},{{item3}},{{...}}]</p> <!-- Output -->

Not very sexy so far, but Mustache also allows to loop on arrays, to only retrieve its content:

<p>{{#pool_id_rewards}}{{name}}{{/pool_id_rewards}}</p> <!-- Input -->
<p>{{item1.name}}{{item2.name}}{{item3.name}}{{...}}</p> <!-- Output, return the "name" property of each reward -->

And even to filter them, removing unwanted values:

<p>{{#pool_id_rewards}}{{#classic}}{{name}}{{/classic}}{{/pool_id_rewards}}</p> <!-- Input -->
<p>{{item1.name}}{{item3.name}}</p> <!-- Output, only returns the "name" of "classic" rewards -->

In this example, only the "classic" and "bonus" values exist as these are the two types of rewards in the backend.

Obviously, you can still mix this with basic HTML to get a working template, and voilà:

<ul>{{#pool_id_rewards}}{{#classic}}<li>{{name}}</li>{{/classic}}{{/pool_id_rewards}}</ul> <!-- Input -->
<!-- Output, only returns the "name" of "classic" rewards, formatted as an HTML unordered list -->
<ul>
    <li>{{item1.name}}</li>
    <li>{{item3.name}}</li>
</ul>

Enjoy! 😌

{{#value}} content to display if true {{/value}}
{{^value}} content to display if false {{/value}}

<ul>
    <li>{{item1.name}}</li>
    <li>Invalid</li>
    <li>{{item3.name}}</li>
    <li>Invalid</li>
</ul>

Variables

reward_name
reward_description
reward_code
reward_image
reward_custom_data
reward_coupon_code
bonus_name
bonus_description
bonus_code
bonus_image
bonus_custom_data
bonus_coupon_code
pool_id_rewards
smart_odds
smart_value
odds
currency
value
integer_value_played
session_id
email
phone
firstname
lastname
item_uid
user_uid
ip
short_url
coupon_code
play_url
email_play_url
email_full_play_url
draw_hash
hash
formatted_hash
segment
data

# OPERATION specific
name
description
store_name
scratch_percent
item_value
value_computed
# OPERATION specific END

language
iban
bic
shipping_costs
keep_me_posted
tc
asset(name)
cluster_odds(name)
method_missing(name, *args, &block)
parent_firstname
parent_lastname
parent_email
unsubscribe_link
share_url
click_share_url_facebook
click_share_url_email
click_share_url_twitter
click_share_url_google
click_share_url_whatsapp
click_share_url_direct
poke_data
more
paypal_email
i18n(text)

Barcodes

<img
    src="https://box.lucky-cycle.com/barcode/300/{{coupon_code}}"
    alt="{{coupon_code}}"
/> <!-- with 300 being the height of the image, in pixels -->

Last updated