[stringtemplate-interest] Problem in multivalued attribute
handling?
Colin Bean
ccbean at gmail.com
Fri Jul 7 14:55:16 PDT 2006
Hi Praki,
I noticed a similar issue recently; I hadn't gotten around to looking
at it in depth (I also hadn't verified it in 2.2 yet, but sounds like
its still there). As far as I know, PyST won't render any attribute
(that's passed as an int or float) with a value of zero. I haven't
looked at the source code, but I assume that somewhere there's a
conditional that checks for the value/existence of an attribute, then
checks it in such a way that a 0 evaluates to false and ST doesn't
think that the attribute exists. If you're passing integer values
into a template, casting them to a string before passing them causes
all zero values to render correctly (that's the workaround I've been
using for now, anyway).
So I haven't verified if this is expected behavior or if this is
unique to the python implementation, but I've noticed the same
behavior. I'm on vacation this weekend, so I don't have any ST code
near at hand, but when I get back I'll verify the above assumptions
and report back ;)
Anyone else? Is this a feature or a bug?
Thanks,
-Colin
On 7/6/06, Praki Prakash <praki.prakash at gmail.com> wrote:
> Hi,
>
> While using the Python version of StringTemplate, I noticed that my
> multivalued attribute was missing all the zero values. The following snippet
> demonstrates the problem. I am using version 2.2. Is this a bug? Is there a
> workaround?
>
> >>> import stringtemplate
> >>> st=stringtemplate.StringTemplate("$[0,1,0,1]:{$it$}$")
> >>> print st
> 11
>
> Thanks
> Praki
> _______________________________________________
> stringtemplate-interest mailing list
> stringtemplate-interest at antlr.org
> http://www.antlr.org:8080/mailman/listinfo/stringtemplate-interest
>
>
>
More information about the stringtemplate-interest
mailing list