Branching Logic
A simple method of conditionally rendering content lies in LXPâs native support for a small set of branching logic tags. These allow you to either display or hide regions of markup by performing equivalence checks on variables or cookies. LXPâs basic branching logic tags include:
<if>
<ifnot>
<ifcookie>
<ifnotcookie>
<else>
<elseif>
<elseifnot>
The <if>
and <ifnot>
tags operate on LXP
variables (or object variable values), whereas the <ifcookie> and <ifnotcookie>
tags operate on stored cookies for the current domain. In other words, the logical functions of
<if>
and <ifcookie>
are the same; only the
sources for logical evaluation differ.
The <else>
tag is more generalized, and implements subsequent,
inverted logic evaluations on any of the previously mentioned tags. The <elseif>
and <elseifnot>
tags are actually just
shortcut tags with the same result as nesting an <if>
or <ifnot>
tag within an <else>
region.
The <if> and <ifnot> Tags
When used without any
accompanying attributes, the <if>
and <ifnot>
tags perform no useful function. However, with meaningful
attributes, these tags can be used to quickly and simply flag regions of mark-up for display
under specific circumstances.
Using <if>
The <if>
tag examines its defined attributes through
equivalence comparisons to variables whose names match the attribute names. If the specified
attributeâs value matches the variableâs value exactly, the region of mark-up between that
<if>
and its associated </if>
closing tag will ...
Get Practical PostgreSQL now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.