πŸ₯Έ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:

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

Enjoy! 😌

Variables

Barcodes

Last updated