Главная страница


ru.cgi.perl

 
 - RU.CGI.PERL ------------------------------------------------------------------
 From : Dmitry Tsigelnik                     2:5020/400     17 Dec 2003  12:33:41
 To : Alexey Mahotkin
 Subject : Re: TT2
 -------------------------------------------------------------------------------- 
 
 Alexey Mahotkin пишет:
 
 AM> Мой, что ли, патч? У меня всё читает в правильной кодировке.  
 
 Покажи, как
 
 AM> ты зовёшь HTML::Template и где взял патч?
 
 AM> --alexm
 То что читает не в той кодировке, жаловался мой начальник, сам я 
 tmpl_include c этим патчем не использовал.
 Этот?
 - --- Template.pm 2003/04/30 15:51:51 1.1.1.1
 +++ Template.pm 2003/05/28 13:04:24 1.5
 @@ -628,6 +628,16 @@
  
  =item *
  
 +perlio_layer - if set then do the additional binmode() call to set the
 +PerlIO layer (in Perl 5.8.0+).  Usually used to handle templates in
 +UTF-8.  Example:
 +
 +   my $template = HTML::Template->new( filename => 'file.tmpl',
 +          perlio_layer => ':utf8',
 +               );
 +
 +=item *
 +
  search_path_on_include - if set to a true value the module will search
  from the top of the array of paths specified by the path option on
  every <TMPL_INCLUDE> and use the first matching template found.  The
 @@ -1583,15 +1593,9 @@
        $options->{filepath} = $filepath;   
      }
  
 -    confess("HTML::Template->new() : Cannot open included file 
 $options->{filename} : $!")
 -   unless defined(open(TEMPLATE, $filepath));
 +    $self->{template} = $self->_read_template_file($filepath, $options-
 
 >{filename}, $options);
 
      $self->{mtime} = $self->_mtime($filepath);
  
 -    # read into scalar, note the mtime for the record
 -    $self->{template} = "";
 -    while (read(TEMPLATE, $self->{template}, 10240, length($self->
 {template}))) {}
 -    close(TEMPLATE);
 -
    } elsif (exists($options->{scalarref})) {
      # copy in the template text
      $self->{template} = ${$options->{scalarref}};
 @@ -1621,6 +1625,28 @@
    return $self;
  }
  
 +sub _read_template_file {
 +  my $self = shift;
 +  my $filepath = shift;
 +  my $filename = shift;
 +  my $options = shift;
 +
 +  confess("HTML::Template->new() : Cannot open included file 
 $filename : $!")
 +    unless defined(open(TEMPLATE, $filepath));
 +
 +  if ($options->{perlio_layer}) {
 +    binmode TEMPLATE, $options->{perlio_layer}
 +      or confess ("HTML::Template->new() : Cannot set PerlIO layer on 
 $filename: $!");
 +  }
 +
 +  # read into scalar
 +  my $template = "";
 +  while (read(TEMPLATE, $template, 10240, length($template))) {}
 +  close(TEMPLATE);
 +
 +  return $template;
 +}
 +
  # handle calling user defined filters
  sub _call_filters {
    my $self = shift;
 @@ -1907,7 +1933,8 @@
         (.*) # $19 => $post - text that comes after the tag
        $/sx) {
  
 -      $which = uc($1); # which tag is it
 +      $which = $1;
 +      $which = uc($which); # which tag is it
  
        $escape = defined $5 ? $5 : defined $15 ? $15 : 0; # escape set?
        
 @@ -2177,14 +2204,9 @@
   }
   die "HTML::Template->new() : Cannot open included file $filename : 
 file not found."
     unless defined($filepath);
 - die "HTML::Template->new() : Cannot open included file $filename : $!"
 -   unless defined(open(TEMPLATE, $filepath));        
 - 
 - # read into the array
 - my $included_template = "";
 -   while(read(TEMPLATE, $included_template, 10240, length
 ($included_template))) {}
 - close(TEMPLATE);
 - 
 +
 + my $included_template = $self->_read_template_file($filepath, 
 $filename, $options);
 +
   # call filters if necessary
   $self->_call_filters(\$included_template) if @{$options->{filter}};
 
 --------------------
 Dmitry Tsigelnik
 -- 
 Отправлено через сервер Форумы@mail.ru - http://talk.mail.ru
 --- ifmail v.2.15dev5.1
  * Origin: Talk.ru (2:5020/400)
 
 

Вернуться к списку тем, сортированных по:

 Тема:    Автор:    Дата:  
 TT2   Dmitry Tsigelnik   12 Dec 2003 20:56:28 
 Re: TT2   Ivan Frolcov   12 Dec 2003 23:00:17 
 Re: TT2   Denis Poznyakov   13 Dec 2003 18:38:13 
 Re: TT2   Sergey Borodich   15 Dec 2003 19:58:00 
 Re: TT2   Konstantin Tokar   15 Dec 2003 21:54:09 
 Re: TT2   Ivan Frolcov   16 Dec 2003 10:30:15 
 Re: TT2   Dmitry Tsigelnik   16 Dec 2003 12:40:14 
 Re: TT2   Alexey Mahotkin   17 Dec 2003 00:09:33 
 Re: TT2   Dmitry Tsigelnik   17 Dec 2003 12:33:41 
 Re: TT2   Alexey Mahotkin   18 Dec 2003 00:18:51 
 Re: TT2   Dmitry Tsigelnik   18 Dec 2003 12:37:01 
 Re: TT2   Konstantin Tokar   17 Dec 2003 00:54:19 
 Re: TT2   Dmitry Tsigelnik   17 Dec 2003 12:41:31 
 Re: TT2   Dmitry Tsigelnik   19 Dec 2003 15:14:53 
 Re: TT2   Dmitry Tsigelnik   19 Dec 2003 16:07:59 
Архивное /ru.cgi.perl/64882d8a16c6.html, оценка 2 из 5, голосов 10
Яндекс.Метрика
Valid HTML 4.01 Transitional