Like the name, <b:class> is an singleton tag to injecting class attribute to their parent. Almost same as <b:attr> but this one cant overwrite existing parent value.
<b:class> Syntax and Attribute
BLOGGER XML LANGUAGE
<b:class cond='EXPRESSION'
name='STRING'/>
<b:class cond='EXPRESSION'
expr:name='EXPRESSION'/>
<b:class> Examples
ADD A CLASS
<p>
<b:class name='foo'/>
</p>
The new class foo will be added to the parent tag <p> in the HTML rendering.
ADD A CLASS WITH A CONDITION
<div>
<b:class cond='data:view.isHomepage' name='foo'/>
</div>
The foo class will be added to the parent tag <p> in HTML rendering only if the current page is the homepage.
ADD A CLASS TO AN EXISTING CLASS
<div class='foo'>
<b:class name='bar'/>
</div>
This example injecting class bar to the parent tag <div> in the HTML rendering. and existing classes in the parent tag are retained.
RESULT
<div class='foo bar'>
</div>
INJECTING MULTIPLE CLASSES
<div class='foo'>
<b:class name='bar'/>
<b:class name='baz'/>
</div>
The new classes bar and baz will be added to the parent tag <div> in the HTML rendering and Existing classes in the parent tag are untouched.
RESULT
<div class='foo bar baz'>
</div>
WITH TERNARY OPERATION
<div>
<b:class expr:name='data:view.isHomepage ? "foo" : "bar"'/>
</div>
With an expression in ternary operation, like this example, if the current view is Homepage the class foo will be injected to tag <div>, else bar will be chosen.
Other Tag
- <b:attr>
- <b:case>
- <b:comment>
- <b:default>
- <b:defaultmarkup>
- <b:defaultmarkups>
- <b:eval>
- <b:else>
- <b:include>
- <b:loop>
- <b:message>
- <b:section>
- <b:skin>
- <b:switch>
- <b:tag>
- <b:template-script>
- <b:template-skin>
- <b:widget>
- <b:widget-setting>
- <b:with>
- <![CDATA[]]>
- <data:.../>