Skip to main content
Windward

Switch and Case Tag Reference

Overview


Tag: Switch Tag: <wr:switch >


 

 

The Switch Tag is a great option to use when you have to test for multiple different conditions. Keep in mind that it will execute towards the first condition (case) that it finds to be true and then exit. If there are multiple conditions which are true, only the first one will be acted upon.

 

When a Switch Tag is found in a template, our reporting logic finds the first Case Tag that has a "true" condition and executes everything between that Case Tag and the next Case Tag (or if it is the last Case Tag, everything to the end Case Tag).

 

Always be sure to insert the start and end Switch Tags!

 

Attributes

The switch itself does not contain any attributes.

 

Examples

Download a Switch Tag sample template. This template uses the Windward public SQL Server database and requires an active internet connection.

Note that while the following examples only contain two case statements, we have no limitations in the number of Case Tags that can be used.

 

Note that the Switch and EndSwitch tags do not need to contain statements to evaluate. The Case Tags should contain the statements or values that you want to compare. 

 

Example 1 - First Case is true

Given a template with the following tags,

<switch>

<case select='=1=1' />

First case is true!

<case select='=1=2' />

Second case is true! 

</switch>

 

Example Output 1

First case is true!

 

Example 2 - Second Case is True

<switch>

<case select='=1=2' />

First case is true!

<case select='=1=1' />

Second case is true!

</switch>

 

Example Output 2

Second case is true!

 

Example 3 - Neither Case is True

<switch>

<case select='=1=2'/>

First case is true!

<case select='=1=3'/>

Second case is true!

</switch>

 

Example Output 3

(No output)

 

Example 4 - Both Cases are True

<switch>

<case select='=1=1'/>

First case is true!

<case select='=2=2'/>

Second case is also true!

</switch>

 

Example Output 4 - Only the First True Condition is Output

First case is true!

  • Was this article helpful?