[ZPT] whitespace bug

Martijn Pieters mj@zope.com
Wed, 20 Nov 2002 11:05:36 -0500


On Wed, Nov 20, 2002 at 10:30:19AM +0000, Chris Withers wrote:
> Clemens Robbenhaar wrote:
> > > Suppose I want to generate this:
> > > 
> > >   <span>0</span><span>1</span><span>2</span>
> > > 
> > > That is, I don't want any whitespace between generated elements.
> > > 
> > > This won't work:
> > > 
> > >   <span tal:repeat="n python:range(3)" tal:content="n"></span>
> 
> It should, IMNSHO. Can you file a collector issue at 
> http://collector.zope.org?

Why is this a bug?

> > Add a dummy tag around the one using for repetition, e.g.
> >
> ><tal:block><span tal:repeat="n python:range(3)" 
> >tal:content="n"></span></tal:block>
> 
> That's pretty weird. I wonder why wrapping the tag in a useless block 
> causes whitespace not to be emitted?
> 
> *grumble* bug *grumble*

This is intended behaviour; whitespace surrounding a repeated tag is
repeated as well. Otherwise there would be no way to preserve whitespace in
between repeated items!

Putting the repeated tag directly inside another eliminated the whitespace
(including the newline) and was thus not repeated.

The whitespace included is limited to the whitespace on the line, IIRC. This
is reasonable and confirms to the XML specs. It may be (although I doubt it)
that the xml:space attribute is supported, but how ZPT should react if
xml:space is set to preserve is a whole different kettle of fish.

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