The recent discussion on CHOMPing white space has prodded me to take
another cut at a question I raised some time back "Chomping without
joining lines" 2004/12/15 . There was some thought then about
extending the CHOMPing config to allow a regexp, but that idea seems not
to have crystallized.
Here's another approach to my request:
The basic idea is perhaps the opposite of the recent discussion.
My goal is *minimal* "chomping" , namely:
- If the white space is part of the text, keep it.
- But if a blank line was generated entirely by the TT markup, drop it.
Most important in this is that text that originated from separate lines
should remain on separate lines. The motivation is the use of TT to
generate Apache configurations that are generated centrally and distributed
to the live Apache servers:
- I have to be careful about joining lines because line breaks matter
in the application.
- I want to keep indentation and intentional blank lines, while discarding
spurious blank lines, because that makes the output file easier to
eye-ball, which I occasionally do in addition to feeding the file
to Apache.
It seems to me that CHOMPing operates at a token level, while what I
have in mind is more line-oriented:
(1) If the source line is empty or all white-space, keep it.
(2) If the expanded line is empty or all white-space, but the source
was not (ie contained TT markup), drop it.
(3) Keep everything else as is.
I am now working around this by:
- Turning off all CHOMPing
- Using '#' to get as close as I can to a blank line, where I want that.
- Removing empty and blank lines from the final TT output
My workaround cannot do exactly as I want, since a post-processor can't
distinguish cases (1) and (2). It would also be nice not to require
an extra pass through the data for the post-processing.
So my request boils down to an option something like
"NO_GENERATED_BLANK_LINES" but preferrably with a shorter name.
Does this make sense? Is it of interest to anyone else?
Thanks,
-Len Weisberg
_______________________________________________
templates mailing list
[email protected]
http://lists.template-toolkit.org/mailman/listinfo/templates