A template loop is a template file construct which allows you to iterate through the collection of repository field templates that CodeGen has information about. In order to use template loops you must be generating code based on the content of a repository that contains one or more template field definitions.
Template loops are delimited by a matching pair of <TEMPLATE_LOOP> and </TEMPLATE_LOOP> tags that surround the template code to be inserted for each template. The code between the opening and closing tags is repeated for each template processed. This code may contain any other tokens.
Template loops can contain code that is to be repeated for each template being processed. CodeGen simply repeats the code between the opening and closing template loop tokens the appropriate number of times based on the number of templates being processed.
There are two types of template loops, called multi-line template loops, and in-line template loops.
Multi-Line Template Loops
Multi-line template loops occur when the opening and closing template loop tags appear on separate lines in a template file, and delimit one or more entire lines of template code, like this:
Multi-line template loops generate one or more lines of output code for each template that is processed.
In-Line Template Loops
In-line template loops exist when the opening and closing template loop tags appear on the same line in a template file, and delimit part of a line of template code, like this:
[code] <TEMPLATE_LOOP> code </TEMPLATE_LOOP> [code]
In-line template loops generate code into the current output line.
Copyright © 2021 Synergex International, Inc.