Else Tag
The else tag adds increased power to the if tag. By default, the if tag has a third part that is understood but not explicitly stated:
- If the condition isn't met, do nothing.
You can change this, however. If the if tag condition is not met, you can tell the document template to do something else. To achieve this, you need to use the else tag. For example, the report could insert the text "Outside North America" for cities outside the continent.
In other words, you can have an if tag without an else tag, but you can't have an else tag without an if tag.
Example
Here's a table with an else tag:
Contacts | ||
First Name | Last Name | City |
<forEach tag> <out tag> | <out tag> | <if tag> <out tag> <elsetag> Outside North America <endIf tag> |
<endforEach tag> |
|
|
There are four tags in the city column:
- The if tag sets the condition
- The out tag tells the report what to do if the condition is met
- The else tag tells the report that if the condition set by the if tag isn't met, to do something else: in this case, insert the text "Outside North America"
- The EndIf tag tells the template to stop setting a condition
Just as with the If tag, the Else tag has two parts:
- Evaluating if a condition (set by the If tag) isn't met.
- Determining what to do if the condition isn't met.
And here's the final report:
Contacts | ||
First Name | Last Name | City |
Lisa | Harris | Outside North America |
En-Jay | Hsu | New York |
Tomas | Ramirez | Outside North America |
Kamala | Sharma | Outside North America |