Home > Fluid Dynamics Search Engine > Help > 1096

Customizing HTML: Using Conditional Statements in Templates

FDSE templates support the following conditional statements:

<title>FDSE <% if terms %>: %terms% <% end if %> </title>

...%URL%</A> %admin_options%
Relevance: <% if relevance %> %relevance% <% end if %><% if not relevance %> N/A <% end if %>

Positive conditionals can be written as "if variable". Negative conditionals can be written as either "if not variable" or "unless variable". All conditionals are terminated with "end if". Nesting is not allowed - each conditional extends only to the very next instance of "end if".

The truth or falsehood of a variable is determined by using Perl to evaluate it. Perl 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, including "0", "0.0E23" and "-00.0".

Coding: FDSE conditionals are processed by subroutine PrintTemplate. Modifying the behavior can be done by editing that frequently-called function. The PrintTemplate subroutine modifies template files in this order: 1. parses conditional statements; 2. interpolates replacement values; 3. parses include files and SSI statements.

History: the conditionals feature was added in FDSE version

    "Customizing HTML: Using Conditional Statements in Templates"