Hashtag Loop for Iterating over Bucket Keys
This page uses Hashtag Variable Buckets to demonstrate Bucket Loops.
Values are set using duplicated keys, then all values are processed and displayed grouped by key.
Processing this Hashtag Markup:
<#
set my_bucket.name to "Fruits and Animals";
set my_bucket.items.0.name to "Apple";
set my_bucket.items.0.type to "Fruit";
set my_bucket.items.1.name to "Banana";
set my_bucket.items.1.type to "Fruit";
set my_bucket.items.2.name to "Cat";
set my_bucket.items.2.type to "Animal";
set my_bucket.items.3.name to "Dog";
set my_bucket.items.3.type to "Animal";
#>
<h2><#[my_bucket.name as html]#></h2>
<# start loop for my_bucket.items; #>
<hr>
key = <# key #><br>
value.name = <# value.name #><br>
value.type = <# value.type #><br>
<# end loop #>
Fruits and Animals
key = 0
value.name = Apple
value.type = Fruit
key = 1
value.name = Banana
value.type = Fruit
key = 2
value.name = Cat
value.type = Animal
key = 3
value.name = Dog
value.type = Animal