Chapter 5 Customizing Generation with GTL


.foreach_line macro

This macro is a simple macro that iterates on the lines of the input template specified as the first argument to the macro. The template specified inside the block is translated for each line of the input. This macro creates a new scope with the local variable CurrentLine. This one is defined inside the block to be the i-th line of the input template at iteration i.

.foreach_line (input [,head [,tail]])
	complex-template
.next [(separator)]

The following parameters are available:

Parameter Description
input Input text over which iteration is performed

Type: Simple template
head [optional] Generated before output, if there is one

Type: Text
tail [optional] Appended to the output, if there is one

Type: Text
complex-template Template to apply to each line.

Type: Complex template
separator [optional] Generated between non empty evaluations of complex-template

Type: Text

Example:

.foreach_line(%Comment%)
// %CurrentLine%
.next(\n)

 


Copyright (C) 2008. Sybase Inc. All rights reserved.