Syntax & Usage
Basic Syntax
All Sundial template tags are enclosed within % delimitters. All content outside of delimiters is displayed as static content, or unchanged. When Sundial encounters template tags, it attempts to interpret them, and displays the appropriate output in their place.
Comments
Comments within Sundial are surrounded by asterisks which are themselves surrounded by delimitter tags. For example,
%* I am a comment. Love me. *%
Comments are not displayed in the final output of a template. They are used for making internal notes in the templates.
Control Structures
Sundial supports %if% statements that conditionally include the blocks of template information they surround. %if% statements may be nested. Every %if% statements must be paired with a %endif% statement. %else% and %elseif% are also permitted within %if% ... %endif% statements.
The basic syntax for an %if% statement is as follows:
An expression is evaluated to its boolean (true or false) value. If the expression evaluates to true, Sundial will include the template block surrounded by the %if% statement. Otherwise, the template block will be ignored.
An expression consists of the following:
'<Template_Variable>' <Comparator> '<Value>' |
Note that the and
%if 'Event_Status_Text' = 'Cancelled'% We're sorry, this event is cancelled. %endif% |
In the example above, the message "We're sorry, this event is cancelled." will be displayed within the template if the value of the "Event_Status_Text" template variable is "Cancelled".
Often you want to include one template block if a certain condition is met and a different template block if a condition is not met. To do so, you would include an %else% within your %if% statement. For example,
%if 'Event_Status_Text' = 'Cancelled'% We're sorry, this event is cancelled. %else% This event is a go. %endif% |
The template block following the %else% statement is only executed if the %if% expression evaluated to false, and if there were any %elseif% expressions - only if the evealuted to false as well
%elseif% statements extend %if% statements to include different template blocks in case the original %if% expression evalutes to false. However, unlike %else%, they only include an alternative template block if the %elseif% expression evaluates to true. For example:
%if 'Event_Status_Text' = 'Cancelled'% We're sorry, this event is cancelled. %elseif 'Event_Status_Text' = 'Tentative'% Still deciding whether to have this event. %else% This event is a go. %endif% |
There may be several %elseif% statements within the same %if% statement. The first %elseif% expression that evaluates to true would have its following template block included within the template's output. The %elseif% template block is only included if the preceding %if% expression and any preceding %elseif% expressions evaluated to false and the current %elseif% expresion evaluated to true.
The following comparators are available:
| Comparator | Meaning | |
|---|---|---|
| = | equals | |
| != | not equals | |
| > | greater than | |
| >= | greater than or equal | |
| < | less than | |
| <= | less than or equal | |
Variables
Variables in Sundial can be either displayed directly, used as attributes to other template variables, or used within conditional expressions. To print a variable, simply enclose is in delimiters.
The output of many template variables can be modified by attributes. Attributes to template variables are specified much like HTML attributes. Values should be enclosed in single or double quotes. Sundial will recognize template variables used as attribute values. Sample attribute syntax is as follows:
