Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
PerlMonks  

Re^2: Template Toolkit custom plugins?

by lindex (Friar)
on Oct 04, 2015 at 21:45 UTC ( #1143767=note: print w/replies, xml ) Need Help??


in reply to Re: Template Toolkit custom plugins?
in thread Template Toolkit custom plugins?

I just wanted some different examples of types of plugin usage, the documentation is a little sparse on cookbook examples. My example:
package MyHungryHippo; use strict; use warnings; use 5.16.0; use base qw[Template::Plugin]; sub new { my ($class, $context) = @_; return bless { _context => $context }, $class; } sub nomnom { my $self = shift; return 'eat it'; } 1; package main; use strict; use warnings; use 5.16.0; use Test::More; use_ok 'MyHungryHippo'; use_ok 'Template'; ok my $tt = Template->new({ PLUGINS => { 'HIPPO' => 'MyHungryHippo' } +}); die $tt->error if $tt->error; ok my $tmpl = join('', <DATA>); ok my $output = $tt->context->process( \$tmpl, {} ); like $output, qr/eat/ or diag $output; done_testing(); __DATA__ [% USE HIPPO %] [%- HIPPO.nomnom() -%]

Replies are listed 'Best First'.
Re^3: Template Toolkit custom plugins?
by perlron (Pilgrim) on Oct 05, 2015 at 09:07 UTC

    Hi, Here's an older example of TT usage from merlyn.
    -update-
    Here's another one from the Twiki site, where i see Plugins have a separate Home page .

    Ask not what good Perl n country have done for you, Ask what good you will do for Perl n country

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1143767]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others studying the Monastery: (4)
As of 2022-12-10 09:33 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?