]> wagnertech.de Git - kivitendo-erp.git/blobdiff - SL/Controller/Base.pm
Hilfsfunktion 'render()' zum Rendern von Templates inklusive Titel & $::form->header
[kivitendo-erp.git] / SL / Controller / Base.pm
index a2a380b934b793d6aa52bc8802082639f986e21b..4f6bd196e28425c7831dccffd9c18e054c5d774e 100644 (file)
@@ -37,6 +37,21 @@ sub redirect_to {
   print $::cgi->redirect($url);
 }
 
+sub render {
+  my $self = shift;
+
+  my $template;
+  $template  = shift if scalar(@_) % 2;
+  my %params = @_;
+
+  if ($params{title}) {
+    $::form->{title} = delete $params{title};
+    $::form->header;
+  }
+
+  print $self->parse_html_template($template, $params{locals});
+}
+
 #
 # private functions -- for use in Base only
 #
@@ -157,6 +172,15 @@ Outputs an HTML template. It is a thin wrapper around
 C<Form::parse_html_template> which also adds the current object as the
 template variable C<SELF>.
 
+=item C<render $template, %params>
+
+Renders the template C<$template> by calling
+L</parse_html_template>. C<$params{locals}> will be used as the second
+parameter to L</parse_html_template>.
+
+If C<$params{title}> is trueish then the function also sets
+C<< $::form->{header} >> to that value and calls C<< $::form->header >>.
+
 =item C<url_for $url>
 
 =item C<url_for $params>