How to put "<", ">" in HTML attributes?
Hi, I have a page template, that should have the characters "<" and ">" in the resulting HTML code, e.g.: <input type="hidden", name="xyz", value="<ABC>" /> Zope3 makes a < / &rt; out of the "<>" characters: <input type="hidden", name="xyz", value="<ABC&rt;" Is there a way to get around this automatic conversion? I tried it via: <input .... tal:attributes="value python:'<ABC>'" /> But this makes no difference. Any clues? Best Regards, Hermann P.S.: I know, this seems to make no sense, but the page is a template for another, foreign application, which needs this specific values as placeholders and which I can not adapt... -- hermann@qwer.tk GPG key ID: 299893C7 (on keyservers) FP: 0124 2584 8809 EF2A DBF9 4902 64B4 D16B 2998 93C7
On Wed, 2008-08-20 at 19:34 +0200, Hermann Himmelbauer wrote:
Hi, I have a page template, that should have the characters "<" and ">" in the resulting HTML code, e.g.:
<input type="hidden", name="xyz", value="<ABC>" />
Zope3 makes a < / &rt; out of the "<>" characters:
<input type="hidden", name="xyz", value="<ABC&rt;"
Is there a way to get around this automatic conversion? I tried it via:
<input .... tal:attributes="value python:'<ABC>'" />
But this makes no difference.
Any clues?
Best Regards, Hermann
P.S.: I know, this seems to make no sense, but the page is a template for another, foreign application, which needs this specific values as placeholders and which I can not adapt...
My memory says and the HTML validator acknowledges it: this *is* broken. PT is designed to not do that. Here's how it *might* work: Take a view that generates the broken HTML snippet, like: class View: def code(self): return '<input value="<broken>"/>' And in your template do: <div tal:replace="structure view/code"/> I didn't test it and I'm not sure it works. It might, though. Christian PS: This makes the little internet elves cry. -- Christian Theune · ct@gocept.com gocept gmbh & co. kg · forsterstraße 29 · 06112 halle (saale) · germany http://gocept.com · tel +49 345 1229889 7 · fax +49 345 1229889 1 Zope and Plone consulting and development
Am Mittwoch 20 August 2008 19:59:37 schrieb Christian Theune:
On Wed, 2008-08-20 at 19:34 +0200, Hermann Himmelbauer wrote:
Hi, I have a page template, that should have the characters "<" and ">" in the resulting HTML code, e.g.:
<input type="hidden", name="xyz", value="<ABC>" />
Zope3 makes a < / &rt; out of the "<>" characters:
<input type="hidden", name="xyz", value="<ABC&rt;"
Is there a way to get around this automatic conversion? I tried it via:
<input .... tal:attributes="value python:'<ABC>'" />
But this makes no difference.
Any clues?
Best Regards, Hermann
P.S.: I know, this seems to make no sense, but the page is a template for another, foreign application, which needs this specific values as placeholders and which I can not adapt...
My memory says and the HTML validator acknowledges it: this *is* broken.
PT is designed to not do that.
Here's how it *might* work:
Take a view that generates the broken HTML snippet, like:
class View:
def code(self): return '<input value="<broken>"/>'
And in your template do:
<div tal:replace="structure view/code"/>
I didn't test it and I'm not sure it works. It might, though.
Yes, many thanks for that, this did the trick! Interestingly, something like this did not work:: def attrcode(self): return '<broken>' <input value="" tal:attributes="value view/attrcode" /> Best Regards, Hermann -- hermann@qwer.tk GPG key ID: 299893C7 (on keyservers) FP: 0124 2584 8809 EF2A DBF9 4902 64B4 D16B 2998 93C7
On Thu, 2008-08-21 at 13:30 +0200, Hermann Himmelbauer wrote:
Yes, many thanks for that, this did the trick! Interestingly, something like this did not work::
def attrcode(self): return '<broken>'
<input value="" tal:attributes="value view/attrcode" />
Of course not. The quoting happens because of tal:attributes. Just moving the `python:...` statement into the view code doesn't make a structural difference. What makes it work is the `structure` prefix on the tal:replace part which doesn't touch the result of the evaluation. Christian -- Christian Theune · ct@gocept.com gocept gmbh & co. kg · forsterstraße 29 · 06112 halle (saale) · germany http://gocept.com · tel +49 345 1229889 7 · fax +49 345 1229889 1 Zope and Plone consulting and development
Christian Theune wrote:
PS: This makes the little internet elves cry.
Not to mention coming and finding you in your sleep and cutting your fingers off to prevent you doing it again... Chris -- Simplistix - Content Management, Zope & Python Consulting - http://www.simplistix.co.uk
Hermann Himmelbauer wrote at 2008-8-20 19:34 +0200:
Hi, I have a page template, that should have the characters "<" and ">" in the resulting HTML code, e.g.:
<input type="hidden", name="xyz", value="<ABC>" />
HTML forbids "<" in attributes: it must be represented there as "<". Thus, Zope does the correct thing (as standard conformity is a good thing). -- Dieter
participants (4)
-
Chris Withers -
Christian Theune -
Dieter Maurer -
Hermann Himmelbauer