last : returns true if the current element is the last in the series; works only if the sequence has a
valid size (different from null ).
size : returns the number of elements in the series. This variable is available only if the
Iterator object has one of the methods get_length() or size() .
The previous example can be slightly changed to show the use of the iteration context. The list element
will display something like John is 35 years old [1 of 10] . The persons sequence in that case
could be the result of a SPOD query.
< ul >
::foreach p persons::
< li > ::p.name:: is ::p.age:: old
[::repeat.p.number:: of ::repeat.p.size::] < /li >
::end::
< /ul >
An array in Templo is also accessible using the square brackets syntax. That means that it is possible to
return the name of the first person in the list described in the previous example just using the expression
persons[0].name in the template. It is obvious that this use will not create any iteration context.
The Templo engine provides an alternative way to create loops, the repeat expression; it works just like
a foreach expression but it is applied to an (X)HTML element that is repeated on each cycle.
Pages:
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520