Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 955
Richard Simões Avatar asked Feb 03 '11 01:02

Richard Simões


People also ask

Which directive is used to embed the section into a template?

Template Inheritance The @section directive, as the name implies, defines a section of content, while the @yield directive is used to display the contents of a given section.


2 Answers

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

like image 196
btilly Avatar answered Sep 30 '22 03:09

btilly


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

$stash = { clever => \&do_something};
like image 42
singingfish Avatar answered Sep 30 '22 04:09

singingfish