- Get link
- Other Apps
b:tag
The b:tag tag is a tag for creating a tag or element which is conditionally the container for its children, or contains a dynamic tag name.Any child elements of the b:tag element will be evaluated and rendered, regardless of whether the parent element is created. If the parent element is not created, the children will be appended to the b:tag element's parent element instead.
Attributes
name - Name of the element that will be created, e.g. "div" or "span".
cond - Expression which, when false, causes the container element to be omitted.
cond - Expression which, when false, causes the container element to be omitted.
Note: Attributes which are present on the b:tag element will be copied onto the resulting/created element, if created, except the attributes used by the b:tag element (name and cond).
Example usage
Conditional tag
The following example emits an anchor tag around the blog title, but only if the current view is not the homepage.
The following example emits an anchor tag around the blog title, but only if the current view is not the homepage.
<b:tag name='a'
cond='data:view.url != data:blog.homepageUrl'
expr:href='data:blog.homepageUrl'>
<data:blog.title />
</b:tag>
Dynamic tag names
The following example emits different tags depending on whether the current view is mobile.
The following example emits different tags depending on whether the current view is mobile.
<b:tag expr:name='data:view.isMobile ? "select" : "ul"'
cond='data:view.url != data:blog.homepageUrl'
expr:href='data:blog.homepageUrl'>
<b:loop var='item' values='data:items'>
<b:tag expr:name='data:view.isMobile ? "option" : "li"'>
<data:item.name />
</b:tag>
</b:loop>
</b:tag>