Skip Menu |

This queue is for tickets about the Template-Toolkit CPAN distribution.

Report information
The Basics
Id: 43657
Status: resolved
Priority: 0/
Queue: Template-Toolkit

People
Owner: Nobody in particular
Requestors: DONGXU [...] cpan.org
Cc:
AdminCc:

Bug Information
Severity: Important
Broken in:
  • 2.19
  • 2.20
Fixed in: (no value)



Subject: CHOMP_ALL != CHOMP_ONE
Hi, I suggest not alias CHOMP_ONE to CHOMP_ALL, instead create it as another option. for PRE_CHOMP = CHOMP_ALL: # bin = 'bin' # arg = 'arg' <template> exec [% bin %] [% arg %] </template> it gives: <output> exec binarg </output> the addtional space between [% bin %]<- here ->[% arg %] has been taken away. This is not good for template which produces script. Actually I am thinking of implementing CHOMP_ONE in this way: # if ($chomp == CHOMP_ALL) { # $pre =~ s{ (\n|^) [^\S\n]* \z }{}mx; # } if ($chomp == CHOMP_ONE) { $pre =~ s{ \n [^\S\n]* \z }{}mx; } It won't 'eat' pure space(s) between 2 settings. cheers
This is better: <code> if ($chomp == CHOMP_ALL) { #$pre =~ s{ (\n|^) ([^\S\n]*) \z }{}mx; $pre =~ s{ (\n|^) ([^\S\n]*) \z } {$1 eq "\n" ? '' : ' '}mxe; </code> On Thu Feb 26 10:00:16 2009, DONGXU wrote: Show quoted text
> Hi, > > I suggest not alias CHOMP_ONE to CHOMP_ALL, instead create it as another > option. > > for PRE_CHOMP = CHOMP_ALL: > # bin = 'bin' > # arg = 'arg' > <template> > exec [% bin %] [% arg %] > </template> > it gives: > <output> > exec binarg > </output> > > the addtional space between [% bin %]<- here ->[% arg %] has been taken > away. > This is not good for template which produces script. > > Actually I am thinking of implementing CHOMP_ONE in this way: > > # if ($chomp == CHOMP_ALL) { > # $pre =~ s{ (\n|^) [^\S\n]* \z }{}mx; > # } > if ($chomp == CHOMP_ONE) { > $pre =~ s{ \n [^\S\n]* \z }{}mx; > } > > It won't 'eat' pure space(s) between 2 settings. > > cheers
I agree that it would be good to have a difference between CHOMP_ONE and CHOMP_ALL, but I don't want to break backwards compatibility until version 3.00. As a work-around, you can use '+' at the start or end of a tag to over-ride the default CHOMP setting. e.g. exec [% bin +%] [% arg %] ^ stops the chomp