The tag <b:tag> is an instruction tag to give tag in HTML page. Does not look promising, but if we combine with some condition, then we can make it into different HTML tag with a single <b:tag>.

<b:tag> Syntax and Attribute

Blogger XML Language
<b:tag  cond='EXPRESSION' 
        HTML-ATTRIBUTE='STRING'
        name='STRING'>
 
</b:tag>
  • Not like <b:attr> and <b:class> tags, The <b:tag> can give direct HTML Attribute to the tag.
  • Multiple different HTML-ATTRIBUTE can be used in a single <b:tag>.
  • Both HTML-ATTRIBUTE and name can be used with expr: attribute which give another 'EXPRESSION'.

<b:tag> Examples and Implementation

Normal operation
<b:tag name='div'>
 
</b:tag>
The tag will generate an HTML div tag.
Result
<div>
 
</div>
Add a tag with a condition and extra HTML attribute.
<b:tag cond='data:view.isHomepage' id='foo' class='bar' name='div'>
 
</b:tag>
The new tag div with id 'foo' and class 'bar' will be added in HTML rendering only if the current page is the home page.
Result
<div id='foo' class='bar'>
 
</div>
With ternary operation
<b:tag expr:name='data:view.isHomepage ? "div" : "span"'>
 
</b:tag>
The new <div> will be added if the current page is the homepage. Otherwise, the new tag will be <span> in HTML rendering.
Working with link
<b:tag title='Hi There' expr:class='data:view.isPost ? "foo" : "bar"' expr:href='data:blog.homepageUrl' name='a'>
  <h1>Hello Word</h1>
</b:tag>
<a> Tag with Blog URL and 'Hi There' as title will be added, and if the current view posts he will get 'foo' class, otherwise he got 'bar' class.


Other Tag

Share This

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