[Templates] CHOMP feature request
Clayton Scott
clayton.scott@gmail.com
Sat, 11 Feb 2006 11:52:02 -0500
Did anyone see Template::Parser::Greedy get uploaded to CPAN yesterday?
http://search.cpan.org/dist/Template-Parser-Greedy/
DESCRIPTION
It's easy to write readable templates in Template::Toolkit, and it's
easy to exercise fine-grained control over the output of Template
Toolkit templates. Achieving both at the same time, however, can be
tricky given the default parser's whitespace chomping rules, which
consume no more than one newline character on either side of a
directive.
This means that template authors optimizing for readability (and
writability) may be obliged to compromise the indentation and spacing
of the output and vice versa.
This module allows templates to be laid out in a readable way, while
at the same time enhancing control over the spacing of the generated
output. It does this by providing two new options, CHOMP_GREEDY and
CHOMP_COALESCE, and their corresponding directive modifiers, ~ and ^.
In addition, a new modifier, =3D, for the old CHOMP_COLLAPSE option has
been added.
Clayton
On 2/10/06, mail@seamons.com <mail@seamons.com> wrote:
> > There is one change in functionality with these patches
>
> Actually - there is one more change.
>
> In the old TT behavior if PRE_CHOMP or POST_CHOMP were set to CHOMP_COLLA=
PSE,
> the following would happen:
>
> "[% 1 -%] [%- 2 %]" would result in "1 2". The "-" would have no effect=
-
> which seems a bit odd.
>
> Under the new rules "[% 1 -%] [%- 2 %]" would always result in "12" no m=
atter
> what PRE_CHOMP or POST_CHOMP is set to - which again seems closer to what=
the
> user would desire (at least this user would desire it to do what I told i=
t to
> do - and anecdoteally evidence would suggest that other users would desir=
e
> this also - as there was a Note in in the Config.pod to warn of this
> behavior).
>
> The config_pod.diff file in the prior post file already removes the noted
> exception about the former behavior in TT (since the behavior is now
> removed).
>
> If this is unacceptable, putting the space back in can be accommodated - =
but
> again I think this is more consistent.
>
> Paul Seamons
> mail@seamons.com
>
> _______________________________________________
> templates mailing list
> templates@template-toolkit.org
> http://lists.template-toolkit.org/mailman/listinfo/templates
>
--
Clayton Scott
clayton.scott@gmail.com