Templating System Tag Reference: Switch

## Switch

Templating System : Designer Guide : Tag Reference : Switch

### Summary

The `switch` tag is used to output one of n-sections when the switch variable matches one of the n-case statements. A default section can also be output if none of the n-case statements matches the switch variable.

### Usage Examples

    <switch @x@>
        <case value="Fred">
             Hello Fred.
        </case>
        <case value="Greta">
             Hello Greta.
        </case>
        <case value="Sam">
             Hello Sam
        </case>
        <default>
             I don't recognize your name.
        </default>
    </switch>

Tcl-equivalent flags have the same meaning as in the tcl-switch statement. Supported flags include exact, glob, and regexp.

    <switch flag=glob @x@>
        <case value="F*">
             Hello Fred.
        </case>
        <case value="G*">
             Hello Greta.
        </case>
        <case value="H*">
             Hello Sam
        </case>
        <default>
             You are in the section for people whose names start with F, G, or H.
        </default>
    </switch>

Case tags also have an alternative form for matching a list of items.

    <switch @x@>
        <case in "Fred" "Greta" "Sam">
             Your must be Fred Greta or Sam, but I'm not sure which one.
        </case>
        <default>
             I don't recognize your name.
        </default>
    </switch>

### Notes

- Any legal variables that may be referenced in the template may also be used in `switch` statements.

- Phrases with spaces in them must be enclosed in double quotes and curly braces to be matched correctly. Failure to quote words with spaces correctly results in an error.

        <case "{blue sky}">
          <td bgcolor=#0000ff>
        </case>

templating@arsdigita.com