[stringtemplate-interest] ST new feature request: new expression option: test="..."
Zenaan Harkness
zen at freedbms.net
Sun Apr 20 17:20:21 PDT 2008
>> 3) With the proposed "test" expression option:
>>
>> params(atts) ::= "(<atts:prop(); separator=\",\n\",
>> test=\"it.hasSetter\">)"
>>
>> Yes, now that's clean and elegant, intuitive and Just Works (TM) :)
>>
>> What do others think about such an expression option?
>
> how about
>
>> params(atts) ::= "(<atts:{a | <if(a.hasSetter)><prop(it=a)><endif>;
>> separator=\",\n\")"
I assume that you mean for a closing brace before the semi-colon.
The output this produces is:
(Type1 propertyName1,
type2 propertyName2,
Type3 propertyName3,
)
Note the extra comma, and blank line, at the end of the output.
This is because this particular bean has four properties, and the last
one in the sequence is the one with no setter.
If I also test, by making property2 a getter-only as well, we get:
(Type1 propertyName1,
,
Type3 propertyName3,
)
As you can see, the "separator" gets included for each iteration of the
list, whether or not the inner (anonymous or otherwise) template
produces any output...
This is different to a null element in the list, it is instad a list of
elements, only some of which are to be rendered, based on simple boolean
properties of those elements.
Zen
More information about the stringtemplate-interest
mailing list