[Zope-dev] ZPT attributes and ""

Roger Ineichen dev at projekt01.ch
Wed Mar 18 07:59:32 EDT 2009


Hi Tres
  
> Betreff: Re: [Zope-dev] ZPT attributes and ""
> 
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
> 
> 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()). 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).

Good point

> > I only whould expect that an empty string whould get 
> rendered as "". 
> > And probably we should check the HTML specification and 
> make sure that 
> > we only render empty strings for attributes where they are allowed.
> > 
> > see:
> > http://www.w3.org/TR/html401/types.html#type-name
> > 
> > ID and NAME tokens must begin with a letter ([A-Za-z]) and may be 
> > followed by any number of letters, digits ([0-9]), hyphens ("-"), 
> > underscores ("_"), colons (":"), and periods (".").
> > 
> > This means to me that an empty value for id or name doen't 
> start with 
> > [A-Za-z] and is invalid because is must start with [A-Za-z]. or not?
> 
> - -1 on making ZPT / chameleon responsible for enforcing that 
> requirement:
> that would be the application's job.

Hm, that's a good point too. I see what you are thinking.

My motivation is, it is valid to skip attributes with empty
values for an element in an XML document. (not sure)
If this is true, then there is no reason why a default empty 
values should get rendered.

As far as I know it is valid to skip attributes for empty values
but for some attributes it is not valid to use empty values.

And the bad thing, some attributes need empty values like
you suggested with checked="" etc, oh my ;-)


Regards
Roger Ineichen

> Tres.
> - --
> ===================================================================
> Tres Seaver          +1 540-429-0999          tseaver at palladion.com
> Palladion Software   "Excellence by Design"    http://palladion.com
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v1.4.6 (GNU/Linux)
> Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
> 
> iD8DBQFJwNuY+gerLs4ltQ4RAnvLAJ41d/7G0sHnH7GfX/CV9v+Dw6ksAQCgw+ZC
> LfHPVXRoCkejJLyCvLjdvyU=
> =ClnO
> -----END PGP SIGNATURE-----
> 
> _______________________________________________
> Zope-Dev maillist  -  Zope-Dev at zope.org
> http://mail.zope.org/mailman/listinfo/zope-dev
> **  No cross posts or HTML encoding!  ** (Related lists -  
> http://mail.zope.org/mailman/listinfo/zope-announce
>  http://mail.zope.org/mailman/listinfo/zope )
> 



More information about the Zope-Dev mailing list