It is currently Sun Jan 29, 2023 3:22 pm

b:class

b:class

Post: #1

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

Login

|

Who is online

In total there are 2 users online :: 0 registered, 0 hidden and 2 guests (based on users active over the past 5 minutes)
Most users ever online was 239 on Mon Dec 26, 2022 4:40 am

Statistics

Total posts 4 • Total topics 3 • Total members 1 • Our newest member admin