The Switches Blogger Syntax
BLOGGER XML LANGUAGE
<b:switch var='EXPRESSION'>
<b:case value='EXPRESSION1'/>
<!-- execute case match VALUE1 code block -->
<b:case value='EXPRESSION2'/>
<!-- execute case match VALUE2 code block -->
<b:default/>
<!-- execute case default code block if all case doesn't meet. -->
</b:switch>
Tags <b:switch> can be nest.
Tags <b:switch> and <b:case> must have attribute.
Both <b:switch> and <b:case> value is either Boolean, Number, or String or 'data:' blogger expression.
The tags <b:case> and <b:default> must be nested in a tag <b:switch>.
The <b:case> tags are required and the tag <b:default> is not necessary.
The tag <b:case> can be used multiple times in a tag <b:switch>.
The tag <b:default> can only be used once in a tag <b:switch>.
The tag <b:default> should be the last tag to be mentioned in the switch.
Switches tag Example
WITH STRING
<ul>
<b:loop values='["Fruit","Food","Other"]' var='MyList'>
<li><data:MyList/></li>
<b:switch var='data:MyList'>
<b:case value='Fruit'/>
<b:loop values='["Apple","Mango","Orange"]' var='Fruit'>
<ul>
<li><data:Fruit/></li>
<b:switch var='data:Fruit'>
<b:case value='Apple'/>
<b:loop values='["Gala","Fuji"]' var='Kind'>
<ul>
<li><data:Kind/></li>
</ul>
</b:loop>
</b:switch>
</ul>
</b:loop>
<b:case value='Food'/>
<b:loop values='["Meat","Vegetable"]' var='Food'>
<ul>
<li><data:Food/></li>
</ul>
</b:loop>
<b:default/>
<b:loop values='["Milk","Seafood","Juice","Banana"]' var='Unlisted'>
<ul>
<li><data:Unlisted/></li>
</ul>
</b:loop>
</b:switch>
</b:loop>
</ul>
HTML RENDERED RESULT
- Fruit
- Apple
- Gala
- Fuji
- Mango
- Orange
- Food
- Meat
- Vegetable
- Other
- Milk
- Seafood
- Juice
- Banana
In the example, we have three data in the loop, its ready to print the output. But, before that, he found a Switch and have different case for every data we have earlier. The case is processing main data and adds another data to the main. The process repeat until all Switch and Case fulfilled, so, now our data will look like rendered result above.
Example usage
<b:switch var='data:blog.locale.language'>
<b:case value='fr' />
<b:comment>French</b:comment>
Bonjour monde
<b:case value='it' />
<b:comment>Italian</b:comment>
Ciao mondo
<b:case value='de' />
<b:comment>German</b:comment>
Hallo Welt
<b:default />
<b:comment>Default - English</b:comment>
Hello world
</b:switch>
<title>
<b:switch var='data:blog.pageType'>
<b:case value='index'/>
<data:view.title.escaped/>
<b:case value='item'/>
<data:view.title.escaped/>
<b:case value='static_page'/>
<data:view.title.escaped/>
<b:case value='archive'/>
<data:view.title.escaped/> - <data:messages.blogArchive/> : <data:blog.pageName/>
<b:case value='error_page'/>
Page 404 - <data:view.title.escaped/>
</b:switch>
</title>
<b:switch var='data:view.postId'>
<b:case value='123456789'/>
<!--[data]-->
<b:case value='111222333'/>
<!--[data]-->
<b:case value='...'/>
<!--[data]-->
<b:case value='...'/>
<!--[data]-->
</b:switch>
Reviews
You can use English or Indonesian