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

Share This

About
BloggerBasics101 is licensed under a Creative Commons Attribution-NonCommercial 3.0 Unported License.
Misc
Course