π₯Έ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 -->Please note that an empty or invalid variable will return an empty string ("")!
<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:
Obviously, you can still mix this with basic HTML to get a working template, and voilΓ :
Enjoy! π
[Bonus] Please note that it is also possible to display something for values that doesn't match the filter if wished:
Variables
Barcodes
Last updated