[Templates] Comments create newline characters
C. Chad Wallace
cwallace at lodgingcompany.com
Thu Jul 31 02:09:49 BST 2008
At 6:37 PM on 30 Jul 2008, John Bida wrote:
> Is there a filter that removes the newline character that is created
> by the template comments. For example, if you used the following two
> files
>
>
> textbox.tt
> <html>
> <textarea>[%PROCESS text.tt %]</textarea>
> </html>
>
> text.tt
> [% ## Some type of file header ###%]
> [% ## Some type of file header ###%]
> [% ## Some type of file header ###%]
> [% ## Some type of file header ###%]
> [% ## Some type of file header ###%]
> Line 1
> \n blank line
> [% ## Comment ###%]
> Line 2
> [% ## Comment ###%]
>
> When the html is displayed Line 1 and Line 2 are on the 6th and 9th
> lines in the textarea. The comments in the template file are treated
> as blank lines. I have tried the collapse filter, but it gets ride
> of newline characters all together not just the ones caused by the
> comments. I could write a perl program to act as a filter but I am
> not sure how I can distinguish between the newlines created by the
> comments and those that appear in the file. Any suggestions?
Use dashes in your comment tags:
[%- ## Comment ###%]
The dashes can go at the beginning or the end, depending on where you
want the white space to be chomped. I find that doing it on both ends
results in too much chomping, so I usually just put them at the
beginning.
See the 'Chomping Whitespace' section in perldoc
Template::Manual::Syntax.
--
C. Chad Wallace, B.Sc.
The Lodging Company
http://www.skihills.com/
OpenPGP Public Key ID: 0x262208A0
Debian Hint #20: Want to keep track of what version of a package you
have installed (especially useful for those running hybrid stable /
testing / unstable systems)? Check out apt-show-versions.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 197 bytes
Desc: not available
Url : http://mail.template-toolkit.org/pipermail/templates/attachments/20080730/e5811286/attachment.pgp
More information about the templates
mailing list