To compile strings with event information, DPCalendar uses a template engine called mustache.
It works by expanding tags in a template using values provided in a hash or object. Statement from http://mustache.github.com/mustache.5.html
The idea is that mustache should simplify the output customization in your Joomla calendar for non PHP developers. This syntax is mostly used in language strings for notifications or the content plugin.
On most language strings which do need some event data the mustache codes are used. Basically the {{parameter}} describes a variable passed to the output. {{#start_list}} is the beginning of an iteration over a list where the {{/start_list}} tag is the end of it. Mustache ensures the variables are HTML escaped. If you want to render it as it should be , use three mustaches like {{{parameter}}}
More mustache information can be found here.
Here is an example of a DPCalendar output:
{{#events}}<p>{{date}}<br/>{{{description}}}<br/>We are at: {{#location}}{{country}}, {{city}}{{/location}}</p>{{/events}}
will be rendered as
<p>19.02.2012<br/>Example description with <b>HTML</b>content</br>We are at: USA, New York</p>?
It is possible to have som kind of if else logic in mustache. A block with a # defines an array, object or not empty variable. An inverted section begins with a ^ character and catches all empty values. The following example renders the text "No events found, come back later!" when there are no events found:
{{#events calid=9}}<p>{{title}}</p>{{/events}}{{^events}}<p>No events found, come back later!</p>{{/events}}
Keep in mind that {{/events}}{{^events}} must be come directly after each other, no spaces or other characters are allowed, otherwise it fails to render it correctly.
DPCalendar provides a wide range of variables which can be used in a mustache ready text. The text must be started with {{#events}} and end with {{/events}} even when it is only one single event. The event attributes like id, title, url or state are available and the following list of the extra variables which are passed together with the output text to the mustache engine:
Comments (0)