in reply to Template Toolkit custom plugins?
package MyApp::TT::Plugin::BBCodeFilter; use base qw(Template::Plugin::Filter); use Parse::BBCode; my $bbc; sub init { my $self = shift; my $name = $self->{_CONFIG}->{name} || 'bbcode'; $self->install_filter($name); $bbc = Parse::BBCode->new; return $self; } sub filter { my ($self, $text) = @_; $text = $bbc->render($text); return $text; } 1;
my %tpl_settings = ( ... PLUGIN_BASE => 'MyApp::TT::Plugin', ... ); my $tt = Template->new(%tpl_settings);
[% USE BBCodeFilter -%] <p>[% (comments || '(No Comments)') | bbcode %]</p>
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Template Toolkit custom plugins?
by lindex (Friar) on Oct 04, 2015 at 21:45 UTC | |
by perlron (Pilgrim) on Oct 05, 2015 at 09:07 UTC |