[Templates-cvs] cvs commit: Template2/lib Template.pm

cvs@template-toolkit.org cvs@template-toolkit.org
Fri, 17 Sep 2004 08:47:17 +0100


cvs         04/09/17 07:47:17

  Modified:    lib      Template.pm
  Log:
  * added support for named binmodes as fourth argument to process()
    e.g. process($in, $vars, $out, binmode => ':utf8')
  
  Revision  Changes    Path
  2.78      +5 -7      Template2/lib/Template.pm
  
  Index: Template.pm
  ===================================================================
  RCS file: /template-toolkit/Template2/lib/Template.pm,v
  retrieving revision 2.77
  retrieving revision 2.78
  diff -u -r2.77 -r2.78
  --- Template.pm	2004/01/30 19:32:20	2.77
  +++ Template.pm	2004/09/17 07:47:17	2.78
  @@ -17,7 +17,7 @@
   #   modify it under the same terms as Perl itself.
   #
   # REVISION
  -#   $Id: Template.pm,v 2.77 2004/01/30 19:32:20 abw Exp $
  +#   $Id: Template.pm,v 2.78 2004/09/17 07:47:17 abw Exp $
   #
   #========================================================================
    
  @@ -41,11 +41,6 @@
   $VERSION     = '2.13';
   $ERROR       = '';
   $DEBUG       = 0;
  -
  -# we used to default to binary mode for all win32 files but that make
  -# line endings strange, so we're turning it off and letting users set
  -# it explicitly as an argument to process()
  -# $BINMODE     = ($^O eq 'MSWin32') ? 1 : 0;
   $BINMODE     = 0 unless defined $BINMODE;
   
   # preload all modules if we're running under mod_perl
  @@ -196,7 +191,10 @@
               ($error = $@) =~ s/ at \S+ line \d+\n?$//;
           }
           elsif (open(FP, ">$where")) { 
  -            binmode FP if $options->{ binmode };
  +            # binmode option can be 1 or a specific layer, e.g. :utf8
  +            my $bm = $options->{ binmode };
  +            if ($bm == 1) { binmode FP      }
  +            elsif ($bm)   { binmode FP, $bm }
               print FP $$textref;
               close FP;
           }