On 1/29/06, Paul Makepeace <[EMAIL PROTECTED]> wrote:
> Je 2006-01-29 17:12:45 +0000, Randal L. Schwartz skribis:
> >     <td>
> >     [%- IF 1 %]
> >       <img src="foo.jpg">
> >     [%- END %]
> >     </td>
>
> Hmm, did you actually try this? It didn't work for me, nor is it AIUI
> documented to work (although frankly some of the _CHOMP docs were
> confusing to some IRC wonks & I who were futzing with this). The TT
> engine doesn't seem to mess with stuff outside of its tags.

The problem is that you added extra spaces in front of your img tag. 
The chomp support in TT only makes changes up to the first newline it
encounters (whether it is moving forwards (post chomp) or backwards
(pre chomp) in a string)

If you are post chomping, then TT will remove all spaces up to and
including the first newline (unless a non-whitespace character is
found before the newline).  If you are prechomping it works exactly
the same way except working backwards into the string.  All whitespace
up to and including the first newline is chomped (unless a
non-whitespace character is found before the newline).

Since you are post chomping, and there are spaces 'after' the newline,
they are never altered.

use Template;
my $template = Template->new;
$template->process(\*DATA) or die $template->error;
__DATA__
SPACES REMAIN: <td>
[%- IF 1 -%]
  <img src="foo.jpg">
[%- END -%]
</td>

NO EXTRA SPACES: <td>
[%- IF 1 %]
<img src="foo.jpg">
     [%- END %]
</td>

And here is the output:

SPACES REMAIN: <td>  <img src="foo.jpg"></td>
NO EXTRA SPACES: <td><img src="foo.jpg"></td>

Cheers,

Cees

_______________________________________________
templates mailing list
[email protected]
http://lists.template-toolkit.org/mailman/listinfo/templates

Reply via email to