| |||||||||||||||||||||||||
| |||||||||||||||||||||||||
Writing Templates - Property Loop Tags To add property values (types, names, etc.) you have to do a "property loop". Code enclosed in the property loop is going to be generated for as many times as the number of properties defined in the Properties Edit box. There are two versions of a property loop. A multi-line version ($doproperty) and an inline version ($ploop) Multi-line loops
Since version 1.90, an extension to the property loop, allows you to start and end the loop at your preferred point. The syntax of the loop tag is:
If the starting point of the loop is Inline loops An inline loop is a functional expression that iterates through a number of properties and produces a string. It's syntax
is as follows: Inner-loop tags (tags that work inside loops) As mentioned in the Standard Tags page, inside the property loops you can use the following tags: Hungarian notation is sometimes used to denote arguments and member variables. Some coders prefix member variables or arguments in methods with special prefixes. The following tags serve this purpose and although they can be used anywhere in the template, they are normally used inside a property loop:
Examples 1. Multi-line loop // ---- Injectors & Selectors --------------------------------------------- $doproperty$ public void set$Property$ ( $propertytype$ $property$ ) { this.$property$ = $property$; } public $propertytype$ get$Property$ () { return this.$property$; } $loop$ Examples 2. Multi-line loop int productId product_id String productName product_name int productTypeId product_type_id ...and this template... $doproperty$ ($index$) DB field "$fieldname$" is named "$property$" in the code $loop$ ...produces this output: (0) DB field "product_id" is named "productId" in the code (1) DB field "product_name" is named "productName" in the code (2) DB field "product_type_id" is named "productTypeId" in the code Examples 3. Inline loop $ploop(0, 2, '; ')$$property$="$fieldname$"$ploop$ ( $ploop(0, $propertycount$, ', ')$$propertytype$ $property$$ploop$ ) ...produces this output: productId="product_id"; productName="product_name" ( int productId, String productName, int productTypeId ) Examples 3. Inline loop with step and indentation final String CONSTANT = "$ploop(0, $propertycount$, ', ', 3, '"+%EOL%"')$$fieldname$$ploop$"; ...produces this output: final String CONSTANT = "product_id, product_name, product_type_id, "+ "parent_product_id, stitle_id, title_id, "+ "swsku_id, hardware_id, hwgroup_id, "+ "hwsku_id, sbundle_id, bundle_id"; |
|||||||||||||||||||||||||
Copyright ©2000-2006 CyLog Software www.cylog.org | |||||||||||||||||||||||||