<REPEAT>
Return to Reference...| Property | Description | Default |
|---|---|---|
| list | Invokes a method and expects to get an array from the method. This array provides the values to iterate over. | {oid}Array : The default method, if not overridden with a binding, is the oid label with Array appended to it. One usually uses bindings, though. |
| item | This is the iterator. It receives the values from the list. | {oid} : Names the accessor/method that will receive the successive values from the list. |
| key | The key to use when generating the URLs. You usually just want to leave this to the default. | This defaults to the current index in the list. Only mess with this if you think that you know what you are doing, as changing it will mean that from within any method invoked inside of the repeated section, item will not hold the current iteration's value, but rather will hold something else. |
A <REPEAT> is used to create a loop inside of a template. The content that is inside of the tag will be repeated once for each element in list, with the current element of list provided to item. One typically uses this tag with a binding.
Typical Usage (Via A Binding):
Users Online:<br/> <repeat oid="user_list">@user.username<br/> </repeat>
attr_accessor :user
def users
users = []
application.dbpool.getConnection do |ksdbh|
ksdbh.select(:Users) {|u| u.status == 'online'}.each {|user| users << user.dup}
end
users
end
user_list {
item = user
list = users
}
Usage Without A Binding:
Users Online:<br/> <repeat oid="user">@user.username<br/> </repeat>
attr_accessor :user, :userArray
def setup
@userArray = []
application.dbpool.getConnection do |ksdbh|
ksdbh.select(:Users) {|u| u.status == 'online'}.each {|user| @userArray << user.dup}
end
end
A binding is typically used simply because it makes it easy to alter where the list of elements is coming from without having to make any changes to the template itself. One can also use an oid that describes more clearly the nature of the repetition.
Return to Reference...


