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
[EMAIL PROTECTED]
http://lists.template-toolkit.org/mailman/listinfo/templates

Reply via email to