aboutsummaryrefslogtreecommitdiffstats
path: root/vendor/smarty/smarty/docs/designers/language-custom-functions/language-function-cycle.md
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/smarty/smarty/docs/designers/language-custom-functions/language-function-cycle.md')
-rw-r--r--vendor/smarty/smarty/docs/designers/language-custom-functions/language-function-cycle.md42
1 files changed, 20 insertions, 22 deletions
diff --git a/vendor/smarty/smarty/docs/designers/language-custom-functions/language-function-cycle.md b/vendor/smarty/smarty/docs/designers/language-custom-functions/language-function-cycle.md
index 5986e6322..661e490dc 100644
--- a/vendor/smarty/smarty/docs/designers/language-custom-functions/language-function-cycle.md
+++ b/vendor/smarty/smarty/docs/designers/language-custom-functions/language-function-cycle.md
@@ -1,22 +1,23 @@
-{cycle} {#language.function.cycle}
-=======
+# {cycle}
`{cycle}` is used to alternate a set of values. This makes it easy to
for example, alternate 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
- print 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
+## Attributes
+
+| Attribute Name | Required | Description |
+|----------------|----------|-------------------------------------------------------------------------------------------------------------|
+| name | No | The name of the cycle |
+| values | Yes | The values to cycle through, either a comma delimited list (see delimiter attribute), or an array of values |
+| print | No | Whether to print the value or not (defaults to true) |
+| advance | No | Whether or not to advance to the next value (defaults to true) |
+| delimiter | No | The delimiter to use in the values attribute (defaults to ',') |
+| assign | No | The template variable the output will be assigned to |
+| reset | No | The cycle will be set to the first value and not advanced (defaults to false) |
- You can `{cycle}` through more than one set of values in a template
- by supplying a `name` attribute. Give each `{cycle}` an unique
+ by supplying a `name` attribute. Give each `{cycle}` a unique
`name`.
- You can force the current value not to print with the `print`
@@ -30,20 +31,18 @@ through an array of values.
function will be assigned to a template variable instead of being
output to the template.
-<!-- -->
-
-
- {section name=rows loop=$data}
+## Examples
+```smarty
+{section name=rows loop=$data}
<tr class="{cycle values="odd,even"}">
<td>{$data[rows]}</td>
</tr>
- {/section}
-
-
+{/section}
+```
The above template would output:
-
+```html
<tr class="odd">
<td>1</td>
</tr>
@@ -53,5 +52,4 @@ The above template would output:
<tr class="odd">
<td>3</td>
</tr>
-
-
+```