prevent quoting in tal:attributes
How can I prevent quote escaping in tal:attributes? My attribute contains many quotes itself, and ZPT automatically escapes them. Details: I want to calculate the onMouseOver attribute of <img>. This is the desired result: onMouseOver="MM_swapImage('usability', '', '/usability_on_cs.gif',0)" You see that there are many quotes... This is the Python Script excerpt which calculates the onMouseOver string: ## 'name' and 'url_on' are properly calculated... item['onmouseover']='MM_swapImage("' +name+ '", "", "' +url_on+ '", 0)' The result of this when rendered via ZPT is this: onmouseover="MM_swapImage("contacts", "", "/contacts_on_cs.gif", 0)" I need to change those " back to single quotes. In tal:replace I could use the "structure" modifier, but it does not work for tal:attributes. -- Milos Prudek _________________ Most websites are confused chintzy gaudy conflicting tacky unpleasant... unusable. Learn how usable YOUR website is! http://www.spoxdesign.com
Milos Prudek wrote at 2003-9-12 19:19 +0200:
How can I prevent quote escaping in tal:attributes? I fear, you cannot. This is a TAL weakness.
My attribute contains many quotes itself, and ZPT automatically escapes them.
This is not a problem, as quoted quotes are equivalent to unquoted ones. TAL poses a problem when the attribute contains character or entity references (such as Ä). "tal:attributes" quotes them as "Ä" which is not the same as "Ä". Dieter
Dieter Maurer wrote:
Milos Prudek wrote at 2003-9-12 19:19 +0200:
How can I prevent quote escaping in tal:attributes? I fear, you cannot. This is a TAL weakness.
My attribute contains many quotes itself, and ZPT automatically escapes them.
This is not a problem, as quoted quotes are equivalent to unquoted ones.
TAL poses a problem when the attribute contains character or entity references (such as Ä). "tal:attributes" quotes them as "Ä" which is not the same as "Ä".
Does structure not work here? <x tal:attributes="structure name string:Ä"/> cheers, Chris
Does structure not work here?
<x tal:attributes="structure name string:Ä"/>
No. After I changed the original line tal:attributes="structure onMouseOver item/onMouseOver" to tal:attributes="structure onMouseOver item/onMouseOver" Zope gives this error message: Compilation failed TAL.TALDefs.TALError: Invalid variable name "onMouseOver item" in expression 'onMouseOver item/onMouseOver' Am I missing something? -- Milos Prudek _________________ Most websites are confused chintzy gaudy conflicting tacky unpleasant... unusable. Learn how usable YOUR website is! http://www.spoxdesign.com
Chris Withers wrote at 2003-9-15 14:22 +0100:
Dieter Maurer wrote: ...
TAL poses a problem when the attribute contains character or entity references (such as Ä). "tal:attributes" quotes them as "Ä" which is not the same as "Ä".
Does structure not work here?
<x tal:attributes="structure name string:Ä"/>
It does not, neither in the form "structure name expr" nor in the (more correct) form "name structure expr". Both give "bad variable name exceptions". Dieter
participants (3)
-
Chris Withers -
Dieter Maurer -
Milos Prudek