[Templates] Changing the output record separator
Andrew Strader
astrader@ecnext.com
Fri, 4 Aug 2006 12:15:22 -0400
This sounds like a job for a filter!
[% IF os =3D=3D 'windows' %]
[% message | unix2dos %]
[% ELSE %]
[% message %]
[% END %]
I don't think the filter unix2dos comes standard, but you can easily
define it in Perl before the process method gets called. Alternatively,
you can define it in the template code in terms of the replace filter.
Andrew Strader
=20
-----Original Message-----
From: templates-admin@template-toolkit.org
[mailto:templates-admin@template-toolkit.org] On Behalf Of IvorW
Sent: Friday, August 04, 2006 11:45 AM
To: templates@template-toolkit.org
Subject: [Templates] Changing the output record separator
I have a need to output lines of text from TT with full <CR><LF>. This
is because I am using Template Toolkit to generate SWIFT messages, for
which the format requies the carriage return (I'm doing this on Solaris
by the way).
Currently, I have an application that works - using a template with
embedded carriage returns. Unfortunately, these embedded <CR>s have been
foobared by the version control system, which has, as a result, become
very confused about which operating system platform the template file is
for. So, I have resolved to solve this in code, and have a "clean"
template with no embedded control characters.
Rather than hardcoding the output postprocessing, I want to do <CR><LF>
line endings conditionally, based on some logic inside the template.
Is this something others have done already?
What's the simplest way to do it?=20
I was thinking of setting $\ from some embedded [% PERL %]. Would that
work?
Ivor.
_______________________________________________
templates mailing list
templates@template-toolkit.org
http://lists.template-toolkit.org/mailman/listinfo/templates