TAL blocks inside <style> result in parse error

Bug #452259 reported by Wichert Akkerman
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Zope 2
Invalid
Wishlist
Unassigned
Zope 3
Won't Fix
Undecided
Unassigned
grok
Won't Fix
Undecided
Unassigned
zope.tal
Invalid
Undecided
Unassigned

Bug Description

I am trying to create some conditional CSS. This renders correctly:

    <tal:block>
      <style type="text/css">
      </style>
    </tal:block>

but this results in a NestingError:

    <style type="text/css">
      <tal:block>
      </tal:block>
    </style>

This might be related to #143103.

Revision history for this message
Wichert Akkerman (wichert) wrote :

The mystery continues. Take this simple bit of markup:

    <style type="text/css" tal:define="logo webhelpers/sector_logo" tal:condition="python:logo">
        #navigation li#home {
          background: url(<tal:block replace="logo"/>) no-repeat;
        }
    </style>

the rendered output of that is:

    <style type="text/css">
        #navigation li#home {
          background: url(<tal:block replace="logo"/>) no-repeat;
        }
    </style>

For some reason the TAL statement is not executed.

Revision history for this message
Wichert Akkerman (wichert) wrote :

There is a workaround, but it is so awful you might want to avert your eyes before looking at it:

    <tal:block define="logo webhelpers/sector_logo" condition="python:logo">
      <tal:pain replace="structure string:&lt;"/>style type="text/css"<tal:pain replace="structure string:&gt;"/>
        #navigation li#home {
          background: url(<tal:block replace="logo"/>) no-repeat;
        }
      <tal:pain replace="structure string:&lt;"/>/style<tal:pain replace="structure string:&gt;"/>
    </tal:block>

As a final note I'ld like to add that chameleon.zpt does not suffer from this problem.

Revision history for this message
Christian Zagrodnick (zagy) wrote :

The content of <style> is conciderd cdata afaik. What you can do is <style tal:content="

#your css {}
"></style>

Revision history for this message
Wichert Akkerman (wichert) wrote :

I can not think of a good reason to treat the contents of <style> as CDATA, especially in XHTML templates. If you want CDATA you should use the CDATA markers. The current magic treatment of <style> (and <script>) makes it extremely hard to accomplish reasonably common goals.

Tres Seaver (tseaver)
Changed in zope3:
status: New → Won't Fix
Changed in zope2:
importance: Undecided → Wishlist
status: New → Confirmed
Changed in grok:
status: New → Won't Fix
Revision history for this message
Colin Watson (cjwatson) wrote :

The zope.tal project on Launchpad has been archived at the request of the Zope developers (see https://answers.launchpad.net/launchpad/+question/683589 and https://answers.launchpad.net/launchpad/+question/685285). If this bug is still relevant, please refile it at https://github.com/zopefoundation/zope.tal.

Changed in zope.tal:
status: New → Invalid
Revision history for this message
Colin Watson (cjwatson) wrote :

The zope2 project on Launchpad has been archived at the request of the Zope developers (see https://answers.launchpad.net/launchpad/+question/683589 and https://answers.launchpad.net/launchpad/+question/685285). If this bug is still relevant, please refile it at https://github.com/zopefoundation/zope2.

Changed in zope2:
status: Confirmed → Invalid
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.