Prev | Current Page 488 | Next

L. McColl-Sylvester and F. Ponticelli

"Professional haXe and Neko"

Using dot syntax
is only possible to access variables and not functions.
Part II: Server Side, JavaScript, and Flash; Oh My!
254
A simple example follows to illustrate the dot field access.
class Main
{
public static function main()
{
var t = new haxe.Template(???::name::??™s father is ::father.name::???);
trace(t.execute({ name : ???John Doe???,
father : { name : ???John Senior???}}));
}
}
// result is: Main.hx:6: John Doe??™s father is John Senior
Logical Expressions
Sometimes it is useful to put a bit of logic inside the template layer. In this way it is possible to
discriminate whether a certain piece of output has to be displayed or not. The classic if/else/elseif
structures can be applied using the following syntax:
::if (condition)::
text to display when condition is true
::else::
alternative text
::end::
Don ??™ t forget to close the logical block with the ::end:: expression. The ::else:: expression and the
relative alternative text are optional. More alternatives can be added using the ::elseif condition::
expression.


Pages:
476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500