The b:switch tag, or the switch tag, is a tag for specifying the result for multiple possible values of a variable.


var - Variable value on which to switch.

b:switch tags are combined with nested self-closing b:case and b:default tags.


b:case tags are used within a b:switch tag to separate the output for each value case of the variable in the parent b:switch tag.


value - Value which the variable has in order for this case to be rendered.


b:default tags define the default output when none of the other b:case values are the value of the variable in the parent b:switch tag.

Example usage

The following example emits a different greeting for each known language, defaulting to 'Hello world'.
<b:switch var='data:blog.locale.language'>
  <b:case value='fr' />
    Bonjour monde
  <b:case value='it' />
    Ciao mondo
  <b:case value='de' />
    Hallo Welt
  <b:default />
    <b:comment>Default - English</b:comment>
    Hello world

This would produce Bonjour monde on a French blog, Ciao mondo on an Italian blog, etc. Blogs which are not French, German or Italian would be treated as the default, which is English, Hello world.