b:loop Tag - Blogger Tags References

b:loop Tag - Blogger Tags References
Loops allow access to the data contained in a table. In Blogger's XML editor , a loop is implemented using the tag <b:loop>. It provides access to the items of ARRAY.

Loop Syntax:

<b:loop values='ARRAY' var='VARIABLE_NAME'>
<!-- Code to Be Executed Here -->
</b:loop>

Attributes used for b:loop tag

AttributesClassificationPrefix "expr:"DescriptionStrictness
valuesXML Blogger ExpressionauthorizedTable arrayto extract in the loop.
The expected value can be an explicit value, a data item or a Blogger expression whose type is array
To create an expression, use:
  • Array operators
  • Lambda operators (where/first)
  • The Binary / Ternary Operator
Mandatory
varHTML classicauthorizedThe expected value is any variable name that will contain the values of the items in the array.
As an indication, in the gadget model supplied by default, Blogger engineering has chosen for most tables, the name of the table in the singular (without "s"). For example, the variable used for the array data:posts is post.
Mandatory
indexHTML classicauthorizedThe expected value is a character string.
This attribute provides the index number in the loop.
Optional
reverseHTML classicauthorizedThis attribute reverses the direction of the loop.
The expected value must be boolean(boolean). Either true (true) or false (false).
When this attribute is not mentioned the default value is false (false).
The value can also be a Blogger expression, the result of which returns a Boolean value.
Note: The attribute does not affect the numbering of the index.
Optional

Get Items from an Array:

General Example:

<b:loop index='i' expr:reverse='data:view.isArchive' values='data:videos' var='video' >

<!-- INDEX -->
<data:i/>

<!-- ITEM -->
<data:video.itemName/>

</b:loop>

An Object Array - Example:

<b:loop values='data:posts' var='post' >

<!-- ITEM -->
<data:post.title/>

</b:loop>

A singleton Array - Example:

<b:loop values='["Mickey","Donald","Dingo"]' var='character' >

<!-- ITEM -->
<data:character/>

</b:loop>

Conclusion:

That's all about b:loop tag in Blogger Tags References.

Comments

Popular posts from this blog

b:skin and b:template-skin Tags - Blogger Tags References

b:widget Tag - Blogger Tags Reference

Google News Setup Complete Guide