Petr Jakes schrieb:
>> <span class="${{1:'top', 2:...}.get(myvar)}" py:content="..."/>
> 
> hmmm... when trying:
> <span class="${{1:'top', 2:'right'}.get(myvar)}" py:content="myvar"/>
> 
> I have got:
> ........
>   File "/home/petr/TurboGears/virtuos/virtuos/templates/katalog.py",
> line 136
>     current = Element(u'{http://www.w3.org/1999/xhtml}span',
> template_util.make_attrib({u'class': [{1:'top', 2:'right',
> u'.get(myvar)}']}, self._get_assume_encoding()))
>  
> ^
> SyntaxError: invalid syntax
> 
> (sorry for the bad fromating, the ^ was under the ] bracket)

That's because the first } closes the whole expression.

I'm not sure if there is any escaping proper for this, but what at least 
works is to create a small local function for this.

<?python

def class_lookup(myvar):
     return {1 : "top", 2 : "right"}.get(myvar)
?>
<span class="${class_lookup(myvar)}"/>

Diez

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"TurboGears" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/turbogears?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to