[Zope-dev] ZPT attributes and ""

Marius Gedminas marius at gedmin.as
Wed Mar 18 17:30:24 EDT 2009


On Wed, Mar 18, 2009 at 07:31:36AM -0400, Tres Seaver wrote:
> Roger Ineichen wrote:
> > Hi Malthe
> >   
> >> Betreff: [Zope-dev] ZPT attributes and ""
> >>
> >> Currently, if an attribute expression evaluates to any value 
> >> that's boolean False, it's omitted (e.g. 0, "", object()).

object() is true in boolean contexts.

> >> I
> >> think that's unexpected. Instead, attributes should only be 
> >> omitted when the expression evaluates to ``None``.
> > 
> > I think this is better then render empty strings. see below...
> > 
> >> How do folks feel about changing this behavior in 
> >> ``zope.pagetemplate``.
> > 
> > Probably anything else then "" should be skipped. There is no
> > logic why object() or False should get rendered as "".
> 
> Non-true values have special semantics for certain attributes
> ('checked', 'selected', I think).

True values also.

This is a feature of TAL in HTML mode and should be preserved

  <input type="checkbox" tal:attributes="checked some_bool_expr" />

Marius Gedminas
-- 
http://pov.lt/ -- Zope 3 consulting and development
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
Url : http://mail.zope.org/pipermail/zope-dev/attachments/20090318/f27766a7/attachment.bin 


More information about the Zope-Dev mailing list