C# 클래스 DotLiquid.Tags.For

"For" iterates over an array or collection. Several useful variables are available to you within the loop. == Basic usage: {% for item in collection %} {{ forloop.index }}: {{ item.name }} {% endfor %} == Advanced usage: {% for item in collection %}
Item {{ forloop.index }}: {{ item.name }}
{% endfor %} You can also define a limit and offset much like SQL. Remember that offset starts at 0 for the first item. {% for item in collection limit:5 offset:10 %} {{ item.name }} {% end %} To reverse the for loop simply use {% for item in collection reversed %} == Available variables: forloop.name:: 'item-collection' forloop.length:: Length of the loop forloop.index:: The current item's position in the collection; forloop.index starts at 1. This is helpful for non-programmers who start believe the first item in an array is 1, not 0. forloop.index0:: The current item's position in the collection where the first item is 0 forloop.rindex:: Number of items remaining in the loop (length - index) where 1 is the last item. forloop.rindex0:: Number of items remaining in the loop where 0 is the last item. forloop.first:: Returns true if the item is the first item. forloop.last:: Returns true if the item is the last item.
상속: DotLiquid.Block
파일 보기 프로젝트 열기: NewSpring/Rock

공개 메소드들

메소드 설명
Initialize ( string tagName, string markup, List tokens ) : void
Render ( Context context, TextWriter result ) : void

비공개 메소드들

메소드 설명
SliceCollectionUsingEach ( IEnumerable collection, int from, int to ) : List

메소드 상세

Initialize() 공개 메소드

public Initialize ( string tagName, string markup, List tokens ) : void
tagName string
markup string
tokens List
리턴 void

Render() 공개 메소드

public Render ( Context context, TextWriter result ) : void
context Context
result System.IO.TextWriter
리턴 void