Content-type: text/html If Tag

Home
WebGroove is no longer supported. These docs are reference only.


If Tag
This Agent tag handles conditional processing. If a condition is true, the appropriate block is processed. Otherwise the block is ignored entirely. A condition is any valid Perl expression and may contain Agent variable references. Once a successful condition is found, the remaining elseif and else conditions will not be evaluated. You may have as many elseif tags as you like.

Examples
<if !{item:id}>
<set {item:id}="DEFAULT">
</if>


<if {item:type} eq "COOL">
You're cool!
<elseif {item:type} eq "OK">
You're okay.
<else>
You're lame!
</if>


<if {item:state} =~ /az|tx|ca|ny|wa/i>
You're in a cool state!
</if>


Syntax
<if condition>
block of text, HTML, code
<elseif condition>
more stuff
<elseif condition>
yes, more stuff
<else>
even more stuff
</if>


Common Conditional Operators
< = >Numeric less than, equal to, and greater than.
<= != >=Numeric less than/equal to, not equal, and greater than/equal to.
lt eq gtString less than, equal to, and greater than.
le ne geString less than/equal to, not equal, and greater than/equal to.
or andLogical operators can be used to make complex conditions.
|| && !C-style operators for "or", "and" and "not" can be used as well.
=~Perl regular expressions are very cool.


Note to Perl Developers
To save experienced Perl programmers some grief, elsif may be used as an alternate spelling for elseif. You can also use all the Perl conditions you are used to.

See Also
Clear Tag
Perl Resources
Set Tag
Store Tag
Validate Tag

Up To
Agent Tags
Complete Tag Reference


WebGroove® is a registered trademark of Creativision Publishing Corporation