GPX Spinner  
Home
Examples
Help
Download
Links
 

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:

  1. group and sort statements
  2. conditional statements
  3. replacement values
  4. include files (which themselves are recursively evaluated).

 

 

Home   Examples   Help   Download   Links

GPX Spinner is Copyright © 2003-2006 by Lil Devil
The Groundspeak Geocaching Logo is a trademark of Groundspeak, Inc. Used with permission.