This shows you the differences between two versions of the page.
en:public:developer:template_system:tags:expression:caseof [2012/11/15 22:00] admin [Attributes] |
en:public:developer:template_system:tags:expression:caseof [2012/11/19 11:51] (current) admin |
||
---|---|---|---|
Line 1: | Line 1: | ||
- | ===== <#CaseOf> ===== | + | ====== <#CaseOf> ====== |
The purpose of the CaseOf is to allow the value of a variable or expression to control the flow of program execution via a multiway branch. The main reasons for using a CaseOf include improving clarity, by reducing otherwise repetitive coding | The purpose of the CaseOf is to allow the value of a variable or expression to control the flow of program execution via a multiway branch. The main reasons for using a CaseOf include improving clarity, by reducing otherwise repetitive coding | ||
- | ==== Attributes ==== | + | ==== Parameters ==== |
- | + | ||
- | * **expression** - a boolean condition or a number (0 evaluate to false and all other numbers to true). Operators supported: + - * / ( ) OR AND. The tags in the condition are always evaluated before the condition is calculated | + | |
- | * **statement_<a>** - The content (html text or template filename) to return if the expression evaluate to <a> | + | |
- | * ... | + | |
- | * **statement_<n>** - The content (html text or template filename) to return if the expression evaluate to <n> | + | |
+ | ^ Name ^ Mandatory ^ Description ^ | ||
+ | | <html><span style="color:#008000">Expression</span></html> | Yes | An arbitrary expression (string or number). The tags in the expression are always evaluated first | | ||
+ | | <html><span style="color:#008000">Statement_<a></span></html> | No | The content (html text or template filename) to return if the expression evaluate to <a> | | ||
+ | | <html><span style="color:#008000">...</span></html> | ... | ... | | ||
+ | | <html><span style="color:#008000">Statement_<n></span></html> | No | The content (html text or template filename) to return if the expression evaluate to <n> | | ||
+ | | <html><span style="color:#008000">Default</span></html> | No | Default value to return if no result found (else raise an error) | | ||
==== Example ==== | ==== Example ==== | ||
<code> | <code> | ||
- | <#if condition="('<#page_title>' = '') and (<#url_PageNumber> > 1)" | + | <#caseof expression="<#url_PageNumber>" |
- | true="the page title is empty and the page number is greater than 1" | + | statement_0="their is no page" |
- | false="the page title is NOT empty or the page number is NOT greater than 1"> | + | statement_1="their is at least 1 page" |
+ | default="their is at least <#url_PageNumber> pages"> | ||
</code> | </code> |