Richard Simões
Richard Simões

Reputation: 12802

Can I easily add new directives to Template Toolkit for Perl?

I'd like to add my own directives to Template Toolkit instead if adding functions and/or virtual methods via the plugin system. Is this easily doable without delving too deep into Template::Grammar? And are there any examples I could study on CPAN?

Upvotes: 5

Views: 627

Answers (2)

singingfish
singingfish

Reputation: 3167

Personally I've found the best way to extend TT's behaviour is to shove subrefs in the stash:

$stash = { clever => \&do_something};

Upvotes: 2

btilly
btilly

Reputation: 46497

Does the MACRO directive which is described in Template::Manual do what you want?

Upvotes: 5

Related Questions