[stringtemplate-interest] Formatting vs. Escaping in an AttributeRenderer
Udo Borkowski
ub at abego-software.de
Mon Sep 12 00:12:22 PDT 2011
It looks like I still don't understand the context of your questions. Can you give a full "real life" example explaining your issues?
Udo
On 12.09.2011, at 04:28, Tobias Güntner wrote:
> Am 11.09.2011 23:17, schrieb Udo Borkowski:
>>> * It interferes with "normal" renderer usage, i.e., I can either escape
>>> or format, but not both.
>>
>> There are several ways to solve this. Some time ago Colin Fagan
>> suggested a "MultiFormatStringRenderer" that allows specify multiple
>> "formats" in one "format" string.
>
> Well, yes. But I am looking for a cleaner solution (even if this means I
> have to wait for ST5). I don't want to end up with a Swiss army
> knife^wrenderer which can handle dates, numbers, 19 custom model
> objects, which knows 57 vital string transformations ("upper" plus 56
> others) and 21 different escape modes, and which can make tea in 30
> different locales - all controlled by a single format string which
> requires a grammar to parse. ;)
>
>>> * I have to remember to specify the correct format everywhere.
>> Seems like a good idea to me.
>>
>> But maybe I don't get your point. Can you give a concrete example to
>> make it clearer?
>
> It is not a good idea. If I have to remember doing something again and
> again and again, I am bound to forget it now and then. If ST does it by
> default, I cannot forget it. Consequence: I create less bugs.
>
>> In your AttributeRenderer you need to check for the formatString.
> [...]
>> If you don't do this check you will get strange results, like the
>> [start]…[end] you saw.
>
> What I don't understand: Why are string literals fed into an
> AttributeRenderer? After all, it's an AttributeRenderer, not a
> StringLiteralRenderer or TemplateOutputASecondTimeRenderer. ;)
> This just does not make sense to me.
>
> Regards,
> Tobias
>
> _______________________________________________
> 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