tal:content="<expr>" where <expr> evaluates to None omits tag

Bug #379769 reported by Sidnei da Silva
10
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Chamelon Core
Fix Released
Medium
Malthe Borch
Launchpad itself
Invalid
Medium
Sidnei da Silva

Bug Description

If you have an expression that evaluates to None, the tag will be omitted from the output. This is problematic, especially when used with tables, which is pretty common. Consider this for example:

<tr>
  <td>Attribute 1</td>
  <td>Attribute 2</td>
</tr>
<tr tal:repeat="item view/foo">
  <td tal:content="item/attribute1">Attribute 1</td>
  <td tal:content="item/attribute2">Attribute 2</td>
</tr>

In this case, if any of (attribute1, attribute2) is None, the <td> will be omitted, causing a broken table to be generated. There are easy workarounds, but the behaviour is surprising and not backwards compatible, and we should opt for the path of least surprise.

Revision history for this message
Malthe Borch (mborch) wrote :

One compromise, which makes more sense to me is to render this as a self-closing tag, <td />. This enables developers to realize what happened and guard against it.

However, it may be that for z3c.pt, we should have the ZPT behavior.

\malthe

Revision history for this message
Sidnei da Silva (sidnei) wrote :

I believe a self-closing <td/> *might* break some browsers. There are only some tags which are allowed to be self-closing, according to the HTML4 spec (If I remember correctly).

We should definitely have the same behavior as ZPT for z3c.pt. It is fine to be different in chameleon.zpt.

Revision history for this message
Malthe Borch (mborch) wrote : Re: [Bug 379769] Re: tal:content="<expr>" where <expr> evaluates to None omits tag

2009/5/29 Sidnei da Silva <email address hidden>:
> I believe a self-closing <td/> *might* break some browsers. There are
> only some tags which are allowed to be self-closing, according to the
> HTML4 spec (If I remember correctly).

Definitely, but so be it ('fix the template, not the engine").

> We should definitely have the same behavior as ZPT for z3c.pt. It is
> fine to be different in chameleon.zpt.

I agree. I'll look into implementing this.

Sidnei da Silva (sidnei)
Changed in chameleon.core:
assignee: nobody → Malthe (mborch)
importance: Undecided → Medium
Changed in launchpad:
assignee: nobody → Sidnei da Silva (sidnei)
importance: Undecided → Medium
affects: launchpad → launchpad-foundations
Revision history for this message
Malthe Borch (mborch) wrote :

It turns out to be difficult to implement the self-closing variant, so I will go with Sidnei's proposal here.

Changed in chameleon.core:
status: New → Fix Committed
Revision history for this message
Gary Poster (gary) wrote :

We are using the newest chameleon package, *and* we are not actually using chameleon. I can't verify that any problem has been fixed in Launchpad so marking Invalid.

Changed in launchpad-foundations:
status: New → Won't Fix
status: Won't Fix → Invalid
Malthe Borch (mborch)
Changed in chameleon.core:
status: Fix Committed → Fix Released
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.