Latest news, food, business, travel, sport, Tips and Tricks...

Blogger b:tag Tag

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

,