[ZPT] Nesting a Tag in CSS

Martijn Pieters mj@zope.com
Wed, 9 Oct 2002 10:36:37 -0400


On Wed, Oct 09, 2002 at 09:48:02PM +1000, Richard Jones wrote:
> I forget - the decision was made about a year and a half ago, in the early 
> days of ZPT. Maybe someone from ZC can remember, cos I sure can't :)

Templates are supposed to be meaningful even when unrendered. This means
that a template cannot break the rules of HTML, which state that <style> and
<script> tags can *only* contain text content.

There are various workarounds, like the tal:content="string:...." trick
described in other postings on this list. For example:

<style type="text/css" tal:content="string:
p {
    color: ${request/bodycolor};
}
">
p {
    color: red;
}
</style>

The above is legal HTML, will render correctly in a browser even when the
template isn't expanded, and interpolates the 'bodycolor' variable from the
request into your stylesheet.

-- 
Martijn Pieters
| Software Engineer  mailto:mj@zope.com
| Zope Corporation   http://www.zope.com/
| Creators of Zope   http://www.zope.org/
---------------------------------------------