X-Git-Url: http://wagnertech.de/gitweb/gitweb.cgi/mfinanz.git/blobdiff_plain/2bc66c6238f498521ea7265444d41eb7fbcf6b05..d445880375bce1462b8f9a8b1a502b34c296d41f:/SL/Template/Plugin/P.pm diff --git a/SL/Template/Plugin/P.pm b/SL/Template/Plugin/P.pm new file mode 100644 index 000000000..d2f442354 --- /dev/null +++ b/SL/Template/Plugin/P.pm @@ -0,0 +1,106 @@ +package SL::Template::Plugin::P; + +use base qw( Template::Plugin ); + +use SL::Presenter; +use SL::Presenter::EscapedText; + +use strict; + +sub new { + my ($class, $context, @args) = @_; + + return bless { + CONTEXT => $context, + }, $class; +} + +sub escape { + my ($self, $string) = @_; + return SL::Presenter::EscapedText->new(text => $string); +} + +sub AUTOLOAD { + our $AUTOLOAD; + + my ($self, @args) = @_; + + my $presenter = SL::Presenter->get; + my $method = $AUTOLOAD; + $method =~ s/.*:://; + + return '' unless $presenter->can($method); + + splice @args, -1, 1, %{ $args[-1] } if @args && (ref($args[-1]) eq 'HASH'); + + $presenter->$method(@args); +} + +1; + +__END__ + +=pod + +=encoding utf8 + +=head1 NAME + +SL::Template::Plugin::P - Template plugin for the presentation layer + +=head1 SYNOPSIS + + [% USE P %] + + Customer: [% P.customer(customer) %] + + Linked records: + [% P.grouped_record_list(RECORDS) %] + +=head1 FUNCTIONS + +=over 4 + +=item C + +All unknown functions called on C

are forwarded to functions with +the same name in the global presenter object. + +The presenter's functions use hashes for named-argument +passing. Unfortunately L