[Catalyst] How to use self made Template Toolkit plugins?
J. Shirley
jshirley at gmail.com
Mon Oct 20 16:55:14 BST 2008
On Mon, Oct 20, 2008 at 5:39 AM, <kakimoto at tpg.com.au> wrote:
>
> hi there
> i am thinking of writing some template toolkit plugins for use within
> my *.tt2 files.
>
> I read the Template toolkit book but of course, this is catalyst so some
> things (ie configuration) is different
>
Not really, the hash that is passed into MyApp->config->{'View::TT'}
is passed into TT's ->new, so it is just plain old config. Your
question is also exclusive to Catalyst::View::TT, which is a very
brief RTFS: http://search.cpan.org/src/MRAMBERG/Catalyst-View-TT-0.27/lib/Catalyst/View/TT.pm
That should allow you to figure out how the TT object is being created.
> 1) how do I tell my *.tt2 file that a certain template is to be found in
> a certain location?
>
As documented in Catalyst::View::TT, you just add entries into INCLUDE_PATH
MyApp->config(
'View::TT' => {
INCLUDE_PATH => [
MyApp->path_to( 'root', 'src' ), # root/src
MyApp->path_to( 'root', 'lib' ), # root/lib
],
}
);
> 2) where is the best place (based on best practices) to store the plugin
> files for TT2?
>
The same way every other plugin works. Code it like it is going on
CPAN, and install it - extra points for using local::lib for your
dependencies, too, so you have a separation from your system's site
perl.
-J
More information about the Catalyst
mailing list