Revision 4b782dda
Von Bernd Bleßmann vor mehr als 2 Jahren hinzugefügt
SL/Presenter/ItemsList.pm | ||
---|---|---|
3 | 3 |
use strict; |
4 | 4 |
|
5 | 5 |
use File::Spec; |
6 |
use Template; |
|
7 | 6 |
|
8 | 7 |
use SL::Presenter; |
9 |
use SL::Presenter::EscapedText qw(escape is_escaped); |
|
10 | 8 |
|
11 | 9 |
use Exporter qw(import); |
12 | 10 |
our @EXPORT_OK = qw(items_list); |
... | ... | |
14 | 12 |
sub items_list { |
15 | 13 |
my ($items, %params) = @_; |
16 | 14 |
|
17 |
my $output; |
|
18 |
if (delete $params{as_text}) { |
|
19 |
my $template = Template->new({ INTERPOLATE => 1, |
|
20 |
EVAL_PERL => 0, |
|
21 |
ABSOLUTE => 1, |
|
22 |
CACHE_SIZE => 0, |
|
23 |
ENCODING => 'utf8', |
|
24 |
}); |
|
25 |
die "Could not create Template instance" if !$template; |
|
26 |
my $filename = File::Spec->catfile($::request->layout->webpages_path, qw(presenter items_list items_list.txt)); |
|
27 |
$template->process($filename, {%params, items => $items}, \$output) || die $template->error; |
|
28 |
# Remove last newline because it can cause problems when rendering pdf. |
|
29 |
$output =~ s{\n$}{}x; |
|
30 |
|
|
31 |
} else { |
|
32 |
$output = SL::Presenter->get->render('presenter/items_list/items_list', %params, items => $items); |
|
33 |
} |
|
15 |
my $text_mode = !!delete $params{as_text}; |
|
16 |
my $output = SL::Presenter->get->render('presenter/items_list/items_list', |
|
17 |
{type => $text_mode ? 'text' : 'html'}, |
|
18 |
%params, |
|
19 |
items => $items); |
|
20 |
$output =~ s{\n$}{}x if $text_mode; |
|
34 | 21 |
|
35 | 22 |
return $output; |
36 | 23 |
} |
Auch abrufbar als: Unified diff
Presenter f. Positionsdetails in Belegberichten: Text auch mit render rendern
So ist keine extra Behandlung / keine eigene Template-Instanz nötig.
Dank an Sven.