Re: [Templates] Chomping without joining lines

[prev] [thread] [next] [Date index for 2004/12/15]

From: Len Weisberg
Subject: Re: [Templates] Chomping without joining lines
Date: 20:00 on 15 Dec 2004
On 2004-12-15 11:16 AM, Andy Wardley wrote:
> Len Weisberg wrote:
> 
> >> What I'm looking for is a flavor of a "chomp" option, somewhat
> >> analogous to how CHOMP_COLLAPSE targets the specific needs of HTML.
> 
> Sounds reasonable.  Perhaps in addition to:
> 
>    CHOMP => CHOMP_NONE       (0)
>    CHOMP => CHOMP_REMOVE     (1)
>    CHOMP => CHOMP_COLLAPSE   (2)
> 
> we could also allow CHOMP to be set to any other value to indicate what 
> character(s) you want the whitespace collapsed to.  e.g.
> 
>    CHOMP => "\n"            

> In TT3 there is a new chomp flag '=' to indicate the CHOMP_COLLAPSE
> behaviour, in addition to '-' which does CHOMP_REMOVE.  So with POST_CHOMP 
> set to "\n", you could do this:
> 
>   [% blah =%]    # to collapse to a newline
>   [% blah %]
> 
> and/or this:
> 
>   [% blah -%]    # to remove newline and all whitespace
>   [% blah %]

Sounds like the right idea.  Some questions:

   - Would it be possible for this to preserve indentation?
     Ie preserve leading white space on a line that is not entirely
     white-space ?
     Maybe the rule would be to replace with a single "\n",
     all white space up to and including "\n".
     Is this getting too complicated?

   - If the chomp option were made extensible, seems to me that the
     corresponding chomp flag would need to be extensible also.

   - (I'd suggest that just setting CHOMP to a string or regexp may be
     a bit ambiguous, but I suppose you were just using that as an
     illustration.)

Thanks,

-Len

> A


_______________________________________________
templates mailing list
templates@xxxxxxxxxxxxxxxx.xxx
http://lists.template-toolkit.org/mailman/listinfo/templates

[Templates] Chomping without joining lines
Len Weisberg 18:11 on 15 Dec 2004

Re: [Templates] Chomping without joining lines
Vivek Khera 18:27 on 15 Dec 2004

Re: [Templates] Chomping without joining lines
Len Weisberg 18:56 on 15 Dec 2004

Re: [Templates] Chomping without joining lines
Andy Wardley 19:16 on 15 Dec 2004

Re: [Templates] Chomping without joining lines
Len Weisberg 20:00 on 15 Dec 2004

Generated at 08:56 on 15 Mar 2005 by mariachi v0.52