Using Conditional Statements in Templates
GPX Spinner templates support the following conditional statements:
<% if state %>%state%, <% endif %>%country%
<% unless found %> ... <%if travel_bugs%> ... <%endif%> ... <% endif found %>
Positive conditionals are written as <%if variable%>. Negative conditionals can be written as either
<%if not variable%> or <%unless variable%>. All conditionals are terminated with
either <%endif%> or <%endif variable%>.
Specifying the variable in the endif statement is optional, unless conditional statements are
nested, in which case at least the outer one must include the variable.
As these examples show, spaces at the beginning and end of the statements are optional.
In versions 2.0.6 and earlier, variables are only evaluated for truth or falsehood. They are evaluated by Perl, which
treats the following values as false: an empty string; an undefined value; numeric zero; and any
string that can be interpreted as zero in a numeric context. All other values are considered true.
Starting in version 3.0.0, actual comparisons are possible.
<need examples here>
Template files are evaluated in the following order:
- group and sort statements
- conditional statements
- replacement values
- include files (which themselves are recursively evaluated).
|