Blogger <b:loop> Tag
The b:loop tag lets you repeat a section of content multiple times.- Repeat code multiple times.
- It saves a lot of work.
HTML b:loop Syntax
Each Blogger Loop in your template has opening and closing tags.
<b:loop var='identifier' values='set-of-data'>
Repeated Content Here
</b:loop>
Repeated Content Here
</b:loop>
var can be any name.
values can be any HTML Data.
values can be any HTML Data.
Usage of b:loop Tag
Go to Template > Edit HTML.Blogger Section: new
<html>
<head>
<title><data:blog.pageTitle/></title>
<b:skin/>
</head>
<body>
<b:section id='new'/>
<b:loop var='i' values='1 to 3'>
<li><data:i /></li>
</b:loop>
</body>
</html>
<head>
<title><data:blog.pageTitle/></title>
<b:skin/>
</head>
<body>
<b:section id='new'/>
<b:loop var='i' values='1 to 3'>
<li><data:i /></li>
</b:loop>
</body>
</html>
A loop tag allows you to iterate across an inclusive number range, such as ‘1 to 3', ‘-3 to -9', where the value of the variable takes the number's value.
Control b:loop Tag
Control Blogger Loop with attributes.
<ul>
<b:loop var='number' index='index' values='9 to 7'>
<li>Index: <data:index />, Number: <data:number /></li>
</b:loop>
</ul>
<b:loop var='number' index='index' values='9 to 7'>
<li>Index: <data:index />, Number: <data:number /></li>
</b:loop>
</ul>
This Blogger Loop tags also have an optional index attribute, which gives the zero-based index of the current iteration through the loop.
HTML b:loop Attributes
Attribute | Values | Description |
---|---|---|
var | name | Defines a name for the loop |
values | name | Defines HTML Data for the loop. |
index | value | Defines zero-based index of the current iteration through the loop. |