{cycle} is used to cycle though a set of values. This makes it easy to alternate for example between two or more colors in a table, or cycle through an array of values.
Attribute Name | Type | Required | Default | Description |
---|---|---|---|---|
name | string | No | default | The name of the cycle |
values | mixed | Yes | N/A | The values to cycle through, either a comma delimited list (see delimiter attribute), or an array of values. |
boolean | No | true | Whether to print the value or not | |
advance | boolean | No | true | Whether or not to advance to the next value |
delimiter | string | No | , | The delimiter to use in the values attribute. |
assign | string | No | n/a | the template variable the output will be assigned to |
reset | boolean | No | false | The cycle will be set to the first value and not advanced |
You can {cycle} through more than one set of values in your template by supplying a name attribute. Give each set of values a unique name.
You can force the current value not to print with the print attribute set to false. This would be useful for silently skipping a value.
The advance attribute is used to repeat a value. When set to false, the next call to {cycle} will print the same value.
If you supply the special "assign" attribute, the output of the cycle function will be assigned to a template variable instead of being output to the template.