Use HTML character entity references in attributes


I'd like to use HTML character entity references like &#x6c in an attribute of an element in my template.

Unfortunately the default behavior seems to be, that every & is escaped by &amp - rendering my perfect valid character entity references into gibberish (&amp #x6c).

The only workaround I have found is 11 years old and is using tal:replace and structure see here. This style is contrary to my current implementation and I would really like to avoid it.

I wonder if there are better options today?

In the old days, I had a similar use case. To satisfy it, I had to extend a local Zope copy to support it (I made "structure" and "mtext" available in attributes; where "mtext" allowed character references (the equivalent of "RCData" in SGML).

Nowadays (with the wide spread use of "charset=utf-8"), I no longer see a need for such a use case: just use the unicode character instead of the character reference (If this is not supported by your editor; convert the character references in a post processing).

When I have correctly understood the behavior of modern Plone, then it applies an output transform (e.g. to apply in Plone Diazo themeing). Likely, you can add there a transform step which converts the quoted character references into unicode (if nothing else helps).