During the pre - processing phase of the template
execution, the macros are embedded in the process and replace the expressions they are invoked with.
To use macros it is first necessary to create a special - purpose XML file. This file will contain all of the
macro definitions and it is structured, as shown in the following schema:
< macros >
< macro name=???macroName(argument1, argument2)??? >
< !-- template fragment goes here -- >
< /macro >
< /macros >
Any macro has a name, macroName in the example, and zero or more arguments. The macros element
can contain an unlimited number of macro elements. In a macro body the accessible variables are just the
ones passed as arguments.
Chapter 10: Separating Design Using Templates
267
To invoke a macro inside a template the following syntax is used:
$$macroName(::var1::, other-argument)
Where macroName is obviously the macro to use, ::var1:: is a context variable and other - argument
is a constant string. Because the pre - processor just makes a replacement of the macro calls with
the corresponding macro bodies, arguments do not require any special treatment like quotations.
Pages:
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525