General
Mustache can be used in HTML blocks, email messages templates, print templates – anything. It works by expanding tags in a template using values provided by the myShop engine.
We call it “logic-less” because there are no if statements, else clauses, or for loops. Instead there are only tags. Some tags are replaced with a value, some nothing, and others a series of values. This document explains the different types of Mustache tags and contains a complete list of all the variables.
- Tags
- Reference
- Order
- Order Lines
- General
- Application Subscriptions
- Application Mijnwinkel Plaza
- Application Hurby
Tags
Tags are indicated by the double mustaches. {{person
}} is a variable tag. In the example, we refer to person as the key or tag key.
A {{name
}} tag in a basic template will try to find the variable name
key in the current context. If name
key is not part of the context nothing will be rendered. All variables are expected to be written in lower case.
Example template:
- {{
name
}} - {{
merchant fax
}} - {{
delivery country
}} - {{
shop id
}}
Sections
Sections render blocks of text one or more times, depending on the value of the key in the current context. A section begins with a pound and ends with a slash. That is, {{#orderlines
}} begins a “orderlines” section while {{/orderlines}} ends it.
The behavior of the section is determined by the value of the key. Empty or 0 values or are not rendered. In the example template below, if the person
key exists and the value is empty or 0, the HTML between the pound and slash will not be displayed.
Example template:
{{#person}}
Never shown if person is empty or 0.
{{/person}}
Non-Empty Lists
If the orderlines
key exists and has a non-false value, the HTML between the pound and slash will be rendered and displayed one or more times.
When the value is a non-empty list, the text in the block will be displayed once for each item in the list. The context of the block will be set to the current item for each iteration. In this way we can loop over collections.
Example template:
{{#orderlines}}
<tr><td>{{description}}</td>
<td>{{inc-vat-price-formatted}}</td></tr>
{{/orderlines}}
Inverted Sections
An inverted section begins with a caret (hat) and ends with a slash. That is {{^@person@}} begins a “person” inverted section while {{/person}} ends it.
While sections can be used to render text one or more times based on the value of the key, inverted sections may render text once based on the inverse value of the key. That is, they will be rendered if the key doesn’t exist, is false, or is an empty list.
Example template:
{{#person}}
there is a person
{{/person}}
{{^person}}
No person found
{{/person}}
———————————————————————————————————————————————————————————————————————————————
Reference
Here you find a list of all the variables.
Order variables
Name | Function |
---|---|
price-gross-payment-total | Total price of the order including VAT |
price-gross-payment-total-formatted | Formatted (including currency formatting) total price of the order including VAT |
reference | Reference number of the order |
ordernumber | Reference number of the order |
Order section orderlines
Name | Function |
---|---|
position | Position of the item in the collection starting at 1. |
id | Unique product identification number. |
quantity | Number of items per order line. |
description | Product description. |
title | Optional order line title. |
inc-vat-price-formatted | Product price including value added TAX. |
price-formatted | Product price. |
lid | Unique long identification number of the order line. |
Example template, show a list of all the order lines:
{{#orderlines}}
{{id}}
{{description}}
{{inc-vat-price-formatted}}
{{/orderlines}}
Order delivery fields
Name | Function |
---|---|
afleveradres naam, afleveradres achternaam, delivery surename, delivery name | Delivery name of the customer |
Hello {{delivery name}},
Thank you for your order at..
General fields
Name | Function |
---|---|
link change password | Insert a link to the change password page of a webshop |
nl | Insert a newline in a text message |
tab | Insert a tab in a text message |
Subscription fields
Name | Function |
---|---|
subscription period | Period of the active subscription (months) |
subscription start | Start date of the subscription (dd/mm/yyyy) |
subscription expire | End date of the subscription (dd/mm/yyyy) |
subscription cancelled | Subscription cancelled state [0:active, 1:cancelled] |
Plaza fields
Name | Function |
---|---|
plaza-ordernumber | Order number of the order placed by the customer in the plaza |
Hurby fields
Name | Function |
---|---|
hurby-description | Sign up description message |
hurby-code | Sign up description code |
hurby-ordernumber | Order number assigned by Hurby |
hurby-id | Hurby parcel identification number |
hurby-trackingnumber | Hurby parcel tracking number |
Geef uw reactie op dit onderwerp.