Config Template Looping#

An example of a Config Template (CFT) loops is found in the Phone CFT because the Phone device model contains a list of Lines. In order to set template values for some of these line fields, one needs to iterate over the lines inside the CFT.

CFTs support this looping (foreach) mechanism, as can be seen on the GUI form when looking at a specific CFT instance.

CFT-foreach

The above screenshot illustrates how such a loop (Foreach) can be configured. The CFT is configured to loop over the macro {# input.PhoneX.lines.line #}. Remember, the PhoneX context variable contains a single instance of Phone data. So by referencing lines.line, we are referencing the list of lines associated to this specific Phone.

The Property indicates which field in the CFT we want to extend with each element of the lines.line list. Finally, the contents of each lines.line instance will be stored in {{ cft.LineX }} with each iteration. The cft namespace indicates the origin of the variable LineX.

CFT-lineX

The screenshot above illustrates how the iterated variable can be used in the lines.line field of the CFT.

The first macro in the Display Ascii input box will reference the firstName of the user in the Subscriber context, while the second macro references the pattern of the line instance being iterated over.