Migrated from liquid-for-designers v16

RichMorin
2010-08-12 13:45:51 -07:00
parent 5ca129c3d3
commit beae6b1ce5
+17 -17
@@ -196,21 +196,21 @@ h2. For loops
Liquid allows @for@ loops over collections: Liquid allows @for@ loops over collections:
<pre> <pre>
{% for item in array %} {% for item in array %}
{{ item }} {{ item }}
{% endfor %} {% endfor %}
</pre> </pre>
During every @for@ loop, the following helper variables are available for extra styling needs: During every @for@ loop, the following helper variables are available for extra styling needs:
<pre> <pre>
forloop.length # => length of the entire for loop forloop.length # => length of the entire for loop
forloop.index # => index of the current iteration forloop.index # => index of the current iteration
forloop.index0 # => index of the current iteration (zero based) forloop.index0 # => index of the current iteration (zero based)
forloop.rindex # => how many items are still left? forloop.rindex # => how many items are still left?
forloop.rindex0 # => how many items are still left? (zero based) forloop.rindex0 # => how many items are still left? (zero based)
forloop.first # => is this the first iteration? forloop.first # => is this the first iteration?
forloop.last # => is this the last iternation? forloop.last # => is this the last iternation?
</pre> </pre>
There are several attributes you can use to influence which items you receive in your loop There are several attributes you can use to influence which items you receive in your loop
@@ -219,11 +219,11 @@ There are several attributes you can use to influence which items you receive in
*offset:int* lets you start the collection with the nth item. *offset:int* lets you start the collection with the nth item.
<pre> <pre>
# array = [1,2,3,4,5,6] # array = [1,2,3,4,5,6]
{% for item in array limit:2 offset:2 %} {% for item in array limit:2 offset:2 %}
{{ item }} {{ item }}
{% endfor %} {% endfor %}
# results in 3,4 # results in 3,4
</pre> </pre>
Reversing the loop Reversing the loop
@@ -236,11 +236,11 @@ Instead of looping over an existing collection, you can define a range of number
The range can be defined by both literal and variable numbers: The range can be defined by both literal and variable numbers:
<pre> <pre>
# if item.quantity is 4... # if item.quantity is 4...
{% for i in (1..item.quantity) %} {% for i in (1..item.quantity) %}
{{ i }} {{ i }}
{% endfor %} {% endfor %}
# results in 1,2,3,4 # results in 1,2,3,4
</pre> </pre>
h2. Variable Assignment h2. Variable Assignment