[stringtemplate-interest] Indirect attribute lookup
Terence Parr
parrt at cs.usfca.edu
Sat Sep 6 14:48:10 PDT 2008
On Sep 6, 2008, at 1:38 AM, Roman Odaisky wrote:
> Greetings,
>
>>>>> st = StringTemplate("$(a)$")
>>>>> st["a"] = "b"
>>>>> st["b"] = "c"
>>>>> print unicode(st)
>>
>> b
>>
>> It is my understanding that this is supposed to print “c”. Am I
>> severely
>> mistaken?
>
> Okay, I am, I was inattentive. $(something)$, it turns out, looks
> for a
> template, not attribute.
>
> What I was trying to achieve was:
>
> <tag $["id", "class", "title", etc]:{name|$(name):{$name$="$it$ "}$}/
> >$
>
> the idea was to be able to write
>
> $tag(id={some-id}, title={some-title})$
>
> and to get
>
> <tag id="some-id" title="some-title" />
>
> It turns out indirect attribute lookup is only available as attr.
> (property).
> How can I then create a template like the above?
Can you pass in a map instead of parameters directly?
$foo(amap={...}, id=it)$
the use $amap.(id)$ or somethign?
Ter
More information about the stringtemplate-interest
mailing list