From: Moritz Bunkus Date: Thu, 30 Dec 2010 15:25:39 +0000 (+0100) Subject: Hilfsfunktion 'render()' zum Rendern von Templates inklusive Titel & $::form->header X-Git-Tag: release-2.6.2beta1~17^2~3^2~9 X-Git-Url: http://wagnertech.de/git?a=commitdiff_plain;h=c0f198fa60b783b3fcdabf6e8a2e121bb2794662;p=kivitendo-erp.git Hilfsfunktion 'render()' zum Rendern von Templates inklusive Titel & $::form->header zzgl. notwendiger Anpassung von locales.pl --- diff --git a/SL/Controller/Base.pm b/SL/Controller/Base.pm index a2a380b93..4f6bd196e 100644 --- a/SL/Controller/Base.pm +++ b/SL/Controller/Base.pm @@ -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 which also adds the current object as the template variable C. +=item C + +Renders the template C<$template> by calling +L. C<$params{locals}> will be used as the second +parameter to L. + +If C<$params{title}> is trueish then the function also sets +C<< $::form->{header} >> to that value and calls C<< $::form->header >>. + =item C =item C diff --git a/scripts/locales.pl b/scripts/locales.pl index a5ec52fdc..bdc3852af 100755 --- a/scripts/locales.pl +++ b/scripts/locales.pl @@ -346,7 +346,7 @@ sub scanfile { } # is this a template call? - if (/parse_html_template2?\s*\(\s*[\"\']([\w\/]+)\s*[\"\']/) { + if (/(?:parse_html_template2?|render)\s*\(\s*[\"\']([\w\/]+)\s*[\"\']/) { my $newfile = "$basedir/templates/webpages/$1.html"; if (/parse_html_template2/) { print "E: " . strip_base($file) . " is still using 'parse_html_template2' for " . strip_base($newfile) . ".\n";