b:tag Tag - Blogger Tags References

b:tag Tag - Blogger Tags References
<b:tag> Tag allows you to add a tag under certain conditions. The tag <b:tag> is an XML instruction tag which allows you to add any HTML tag.

Syntax:

<b:tag cond='CONDITION' name='TAG_NAME'>

 <!-- Content Goes Here  -->

<b:tag>

Characteristics:

  • The <b:tag> tag works in all of the XML, except in the tag <b:skin>.
  • Several tags <b:tag> can be combined.
  • Tags <b:tag> can nest.

Attributes Used for this tag:

AttributesClassificationPrefix "expr:"DescriptionStrictness
nameHTML classicauthorizedThe expected value is the name of the tag. Accompanied by the prefix expr:, the value may be:
  • type data string
  • a Blogger expression whose result is of type string
Mandatory
condXML Blogger ExpressionauthorizedCondition of execution of the tag.
The expected value must be boolean ( true or false). It can be an explicit value, a data item or a Blogger expression.
Optional

Some Example Usage:

To add simple tag:

<b:tag name='section'>

</b:tag>

HTML Render:

<section>

</section>

Add Tag by Validating a condition:

<b:tag cond='data:view.isHomepage' name='section'>

</b:tag>

HTML Render:

The new tag section will be added to the HTML rendering only if the current page is the home page.
<section>

</section>

Use of Ternary Operator:

<b:tag expr:name='data:view.isHomepage ? "section" : "div"'>

</b:tag>
The new tag will be section if the current page is home. Otherwise, the new tag will be div in the HTML rendering. Result If True
<section>

</section>
Result if False
<div>

</div>

Add tag with attributes:

<b:tag name='section' class='header'>

</b:tag>

HTML Render:

<section class='header'>

</section>

Conclusion:

The attribute name can conflict, when the tag to generate must also contain an attribute name. To avoid the error, move the attribute name into an attribute tag ( b:attr ).
<b:tag name='div'>

  <b:attr name='name' value='section'/>

</b:tag>

HTML Render:

In HTML rendering, the attribute name is integrated into the tag.
<div name='section'>

</div>
That's all about b:attr Tag in Blogger Tags References.

Post a Comment

Was this article useful? Please Leave Your Feedback by writing what's in your mind, below.

Recent Comments

{getWidget} $results={3} $label={comments} $type={list}