Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision c0f198fa

Von Moritz Bunkus vor fast 14 Jahren hinzugefügt

  • ID c0f198fa60b783b3fcdabf6e8a2e121bb2794662
  • Vorgänger 11093bd5
  • Nachfolger 5a2a3ac3

Hilfsfunktion 'render()' zum Rendern von Templates inklusive Titel & $::form->header

zzgl. notwendiger Anpassung von locales.pl

Unterschiede anzeigen:

SL/Controller/Base.pm
37 37
  print $::cgi->redirect($url);
38 38
}
39 39

  
40
sub render {
41
  my $self = shift;
42

  
43
  my $template;
44
  $template  = shift if scalar(@_) % 2;
45
  my %params = @_;
46

  
47
  if ($params{title}) {
48
    $::form->{title} = delete $params{title};
49
    $::form->header;
50
  }
51

  
52
  print $self->parse_html_template($template, $params{locals});
53
}
54

  
40 55
#
41 56
# private functions -- for use in Base only
42 57
#
......
157 172
C<Form::parse_html_template> which also adds the current object as the
158 173
template variable C<SELF>.
159 174

  
175
=item C<render $template, %params>
176

  
177
Renders the template C<$template> by calling
178
L</parse_html_template>. C<$params{locals}> will be used as the second
179
parameter to L</parse_html_template>.
180

  
181
If C<$params{title}> is trueish then the function also sets
182
C<< $::form->{header} >> to that value and calls C<< $::form->header >>.
183

  
160 184
=item C<url_for $url>
161 185

  
162 186
=item C<url_for $params>
scripts/locales.pl
346 346
      }
347 347

  
348 348
      # is this a template call?
349
      if (/parse_html_template2?\s*\(\s*[\"\']([\w\/]+)\s*[\"\']/) {
349
      if (/(?:parse_html_template2?|render)\s*\(\s*[\"\']([\w\/]+)\s*[\"\']/) {
350 350
        my $newfile = "$basedir/templates/webpages/$1.html";
351 351
        if (/parse_html_template2/) {
352 352
          print "E: " . strip_base($file) . " is still using 'parse_html_template2' for " . strip_base($newfile) . ".\n";

Auch abrufbar als: Unified diff