[Zope-dev] How to put "<", ">" in HTML attributes?

Hermann Himmelbauer dusty at qwer.tk
Thu Aug 21 07:30:20 EDT 2008


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 &lt; / &rt; out of the "<>" characters:
> >
> > <input type="hidden", name="xyz", value="&lt;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 at qwer.tk
GPG key ID: 299893C7 (on keyservers)
FP: 0124 2584 8809 EF2A DBF9  4902 64B4 D16B 2998 93C7


More information about the Zope-Dev mailing list