Most likely you can just transplant the code from here to there.
I tried that but I couldn't get it to work. binmode STDOUT; did work for my platform.
--- tpage 2011-07-12 04:27:14.140625000 -0700 +++ tpage-new2 2011-07-12 04:42:08.796875000 -0700 @@ -39,6 +39,7 @@ # unshift any perl5lib directories onto front of INC unshift(@INC, @{ $config->perl5lib }); +my $binmode = $config->binmode; # get all template_* options from the config and fold keys to UPPER C +ASE my %ttopts = $config->varlist('^template_', 1); my $ttmodule = delete($ttopts{ module }); @@ -67,10 +68,13 @@ my $template = $ttmodule->new($ucttopts) || die $ttmodule->error(); +binmode STDOUT; # process each input file foreach my $file (@ARGV) { $file = \*STDIN if $file eq '-'; - $template->process($file) +#~ $template->process($file, undef, \*STDOUT, $binmode ? {binmode + => $binmode} : {} ) +#~ $template->process($file, undef, \*STDOUT, {binmode => !!$binm +ode} ) + $template->process($file, undef, \*STDOUT, ) || die $template->error(); } @@ -83,6 +87,8 @@ ERROR => sub { die(@_, "\ntry `$NAME --help'\n") } }, 'help|h' => { ACTION => \&help }, + 'binmode=s', + 'template_encoding|encoding=s', 'template_absolute|absolute' => { DEFAULT => 1 }, 'template_relative|relative' => { DEFAULT => 1 }, 'template_module|module=s', @@ -167,6 +173,10 @@ --perl5lib=DIR Specify additional Perl library directori +es --template_module=MODULE Specify alternate Template module +File encoding options + --binmode=value Set binary mode of output files + --encoding=value Set encoding of input files + See 'perldoc tpage' for further information. END_OF_HELP
I also found Template::Parser::LocalizeNewlines which also works
--- tpage 2011-07-12 04:27:14.140625000 -0700 +++ tpage-new 2011-07-12 04:38:37.093750000 -0700 @@ -26,6 +26,7 @@ use strict; use Template; use AppConfig; +use Template::Parser::LocalizeNewlines; my $NAME = "tpage"; my $VERSION = 2.70; @@ -61,6 +62,8 @@ # add current directory to INCLUDE_PATH unshift(@{ $ucttopts->{ INCLUDE_PATH } }, '.'); +$ucttopts->{ PARSER } = Template::Parser::LocalizeNewlines->new ; + # read from STDIN if no files specified push(@ARGV, '-') unless @ARGV;
In reply to Re^2: Template-Toolkit (tt2) tpage newline confusion
by Anonymous Monk
in thread Template-Toolkit (tt2) tpage newline confusion
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |