Do you know where your variables are? | |
PerlMonks |
Re: TT PLUGIN_PATHby matthewb (Curate) |
on Apr 11, 2005 at 16:38 UTC ( [id://446664]=note: print w/replies, xml ) | Need Help?? |
You can include plugins you have defined yourself that are outside of @INC by specifying a relative (to the program that constructs a new Template object) path. Supposing the following output of ls -R:
...where one might use the module Local/MyPlugin.pm with ``use Local::MyPlugin;'', an argument to the constructor of ``PLUGIN_BASE => 'Local','' would allow you to say ``[% USE MyPlugin %]''. A trivial example (using the proposed directory structure) may be illustrated, thus: index.pl:
Local/MyPlugin.pm:
There's a book which explains all this very nicely, personally I found it easier-going than browsing the docs. As for whether you should use your plugin-defining module elsewhere in your application, I can't see an obvious case where you'd want to use code that inherits from Template::Plugin::Base outside of the context of processing templates but, if you can, there's no particular reason you cannot. I would argue that it makes sense to keep your plugin logic packaged separately, if only to make its purpose obvious to a future maintainer. MB
In Section
Seekers of Perl Wisdom
|
|