| 1 | package Application::Pipeline::Services::Template; | ||
| 2 | $VERSION = '0.1'; | ||
| 3 | |||
| 4 | #-- pragmas ---------------------------- | ||
| 5 | use strict; | ||
| 6 | use warnings; | ||
| 7 | |||
| 8 | #-- modules ---------------------------- | ||
| 9 | use Template; | ||
| 10 | |||
| 11 | =head1 Application::Pipeline::Services::Template | ||
| 12 | |||
| 13 | This plugin for Application::Pipeline makes available a template object, | ||
| 14 | which is simply a Template Toolkit instance. To access it from the application: | ||
| 15 | |||
| 16 | $pipeline->loadPlugin( 'Template' ( template constructor arguments ) ); | ||
| 17 | |||
| 18 | $template = $pipeline->template; | ||
| 19 | |||
| 20 | note that the parameters being sent to the Template constructor is not a hash | ||
| 21 | ref (as TT does), but rather a hash. It will be correctly passed to the | ||
| 22 | Template constructor as a hash ref. | ||
| 23 | |||
| 24 | =cut | ||
| 25 | |||
| 26 | #=============================================================================== | ||
| 27 | |||
| 28 | sub load { | ||
| 29 | my( $class, $pipeline, %args ) = @_; | ||
| 30 | my $template = Template->new( \%args ); | ||
| 31 | |||
| 32 | $pipeline->addServices( template => $template ); | ||
| 33 | return $template | ||
| 34 | } | ||
| 35 | |||
| 36 | #======== | ||
| 37 | 1; | ||
| 38 | |||
| 39 | =head2 Authors | ||
| 40 | |||
| 41 | Stephen Howard <stephen@thunkit.com> | ||
| 42 | |||
| 43 | =head2 License | ||
| 44 | |||
| 45 | This module may be distributed under the same terms as Perl itself. | ||
| 46 | |||
| 47 | =cut |