Skip to content. | Skip to navigation

Personal tools

>>> ''.join(word[:3].lower() for word in 'David Isaac Glick'.split())



You are here: Home / Blog / Forcing TAL to render mismatched tags

Forcing TAL to render mismatched tags

by David Glick posted Nov 11, 2008 05:39 PM
Today I installed Google website optimizer for a Plone site. This tool requires the use of a </noscript> tag in order to designate the end of a block that may be used in experiments. Unfortunately, if you try to insert this in a Zope page template you'll see something like this:

Compilation failed
zope.tal.htmltalparser.NestingError: No tags are open to match </noscript>, at line 2, column 1

You can work around this using the following idiom:

<tal:block tal:content="structure string:&amp;lt;/noscript&amp;gt;"/>

This bypasses TAL compilation by parsing the </noscript> as a string, then inserts it into the template as HTML structure. The angle brackets are written as HTML entities so that the template has a chance of passing XML validation.

Credit to Darryl Dixon via #plone on IRC, and my colleague Jon Baldivieso for the HTML entities suggestion. Thanks!

Rob Porter says:
Nov 14, 2008 03:13 AM
very cool and interesting.
Adam says:
Nov 12, 2008 02:31 AM
I actually really like this approach and would try this way. I like seeing the 'forceinvalid' so you know exactly what is being accomplished on the line.<p>&lt;tal:forceinvalid content="structure string:&lt;/noscript&gt;"/&gt;
Eric Steele says:
Nov 12, 2008 03:30 AM
Awesome! Thanks for this.