X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;f=SL%2FController%2FBase.pm;h=876aac30fdfb5f92f6c847dc95371a036987d5ec;hb=e36b34d301ba80bbb8f9ba2fe33608e153f8f71c;hp=aa65645aebb7dbab3c45a5c2b121eb505dacfb59;hpb=7647d46acbc2a8253c0afeac5c706c3eb76995d5;p=kivitendo-erp.git diff --git a/SL/Controller/Base.pm b/SL/Controller/Base.pm index aa65645ae..876aac30f 100644 --- a/SL/Controller/Base.pm +++ b/SL/Controller/Base.pm @@ -60,6 +60,9 @@ sub render { my $template = shift; my ($options, %locals) = (@_ && ref($_[0])) ? @_ : ({ }, @_); + # Special handling/shortcut for an instance of SL::ClientJS: + return $self->render(\$template->to_json, { type => 'json' }) if ref($template) eq 'SL::ClientJS'; + # Set defaults for all available options. my %defaults = ( type => 'html', @@ -80,6 +83,7 @@ sub render { croak "Unsupported type: " . $options->{type} unless $options->{type} =~ m/^(?:html|js|json)$/; # The "template" argument must be a string or a reference to one. + $template = ${ $template } if ((ref($template) || '') eq 'REF') && (ref(${ $template }) eq 'SL::Presenter::EscapedText'); croak "Unsupported 'template' reference type: " . ref($template) if ref($template) && (ref($template) !~ m/^(?:SCALAR|SL::Presenter::EscapedText)$/); # If all output is turned off then don't output the header either. @@ -380,6 +384,11 @@ If C<$template> is a reference to a scalar then the referenced scalar's content is used as the content to process. The C option is not considered in this case. +C<$template> can also be an instance of L +or a reference to such an instance. Both of these cases are handled +the same way as if C<$template> were a reference to a scalar: its +content is processed, and C is not considered. + Other reference types, unknown options and unknown arguments to the C option cause the function to L.