[stringtemplate-interest] Using the "format" option with a template calls
Udo Borkowski
ub at abego-software.de
Tue Jan 25 16:09:12 PST 2011
> Hi. does <(t()); format="upper"> work?
Nearly. It seems it eats (leading) white spaces.
Here my little example group:
-------------------
t() ::= <<
abc
>>
main() ::= <<
«t()»
«t();format="upper"»
«(t());format="upper"»
«t().render;format="upper"
>>
-----------------
Rendering main will produce this output:
-----------------
abc
abc
ABC
ABC
-----------------
3rd line is the (t()) case, 4th line produced by my ST ObjectAdapter.
Udo
On 25.01.2011, at 20:45, Terence Parr wrote:
> Hi. does <(t()); format="upper"> work?
> Ter
> On Jan 25, 2011, at 12:56 AM, Udo Borkowski wrote:
>
>> While the "format" option work fine with attributes, like in
>>
>> <attr;format="upper">
>>
>> it does not seem to work when used together with template invocations, like:
>>
>> <t();format="upper">
>>
>> I don't know if this is intended (e.g. because of performance reasons) or a bug. I personally would like to have the format option also work in the latter situation. E.g. when I "refactor" my templates it happens data once stored in an attribute moves into a template. This was not possible when the "format" option is used.
>>
>>
>> I am currently working around this by using a custom ObjectModelAdapter for ST, using this code:
>>
>> public Object getProperty(ST self, Object o, Object property,
>> String propertyName) throws STNoSuchPropertyException {
>> if ("render".equals(propertyName) && (o instanceof ST)) {
>> return ((ST) o).render();
>> }
>> return super.getProperty(self, o, property, propertyName);
>> }
>>
>> This way the above example looks like this:
>>
>> <t().render;format="upper">
>>
>> While this works fine I am still wondering if the "format" options should also work for the simple template call, too.
>>
>> What do you think?
>>
>> Udo
>>
>> _______________________________________________
>> stringtemplate-interest mailing list
>> stringtemplate-interest at antlr.org
>> http://www.antlr.org/mailman/listinfo/stringtemplate-interest
>
> _______________________________________________
> stringtemplate-interest mailing list
> stringtemplate-interest at antlr.org
> http://www.antlr.org/mailman/listinfo/stringtemplate-interest
More information about the stringtemplate-interest
mailing list