Prev | Current Page 507 | Next

L. McColl-Sylvester and F. Ponticelli

"Professional haXe and Neko"


In the following template, a list of person objects is iterated. Each loop creates a scope variable person.
Inside the foreach structure the person object is accessible as usual using the conventional dot syntax.
< ul >
::foreach person persons::
< li > ::person.name:: is ::person.age:: years old < /li >
::end::
< /ul >
Part II: Server Side, JavaScript, and Flash; Oh My!
264
The foreach structure also automatically creates a few variables that are commonly used in templates
and iterations. Those variables are associated to an object that is accessible using the following naming
convention: repeat.iteration - name.variable - name , where iteration - name is the name defined
in the foreach expression and variable - name is one of the following possibilities:
index : returns the numeric position in the sequence starting from 0.
number : returns the numeric position in the sequence starting from 1.
odd : returns true if index is odd.
even : returns true if index is even.
first : returns true if the current element is the first in the series.


Pages:
495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519