| 1 | =head1 NAME | ||
| 2 | |||
| 3 | Template::TAL::Provider - Base class for TAL template providers | ||
| 4 | |||
| 5 | =head1 SYNOPSIS | ||
| 6 | |||
| 7 | my $provider = $provider_class->new; | ||
| 8 | my $ttt = $provider_class->get_template("foo"); | ||
| 9 | |||
| 10 | =head1 DESCRIPTION | ||
| 11 | |||
| 12 | TAL Templates come from Providers. You ask an instance of a provider for a | ||
| 13 | template with a specific name, and it should return a | ||
| 14 | L<Template::TAL::Template> object to you for that template. | ||
| 15 | |||
| 16 | This module is the base class of all providers - it should be subclassed by | ||
| 17 | developers who wish to write their own provider - for instance, to serve | ||
| 18 | templates from a database. | ||
| 19 | |||
| 20 | =head1 SUBCLASSING | ||
| 21 | |||
| 22 | The only method you need to implement is C<get_template>, which must | ||
| 23 | return either a Template::TAL::Template object, or undef. If you want to | ||
| 24 | do any module initialisation, override C<new()>. See | ||
| 25 | L<Template::TAL::Provider::Disk> for the simple provider that ships with | ||
| 26 | Template::TAL. | ||
| 27 | |||
| 28 | =cut | ||
| 29 | |||
| 30 | package Template::TAL::Provider; | ||
| 31 | use warnings; | ||
| 32 | use strict; | ||
| 33 | use Carp qw( croak ); | ||
| 34 | |||
| 35 | =head1 METHODS | ||
| 36 | |||
| 37 | =over | ||
| 38 | |||
| 39 | =item new() | ||
| 40 | |||
| 41 | creates a new provider | ||
| 42 | |||
| 43 | =cut | ||
| 44 | |||
| 45 | sub new { | ||
| 46 | return bless {}, shift; | ||
| 47 | } | ||
| 48 | |||
| 49 | =item get_template( template name ) | ||
| 50 | |||
| 51 | Should return a Template::TAL::Template object with the given name, or die | ||
| 52 | if there is no such template. | ||
| 53 | |||
| 54 | =cut | ||
| 55 | |||
| 56 | sub get_template { | ||
| 57 | croak('Template::TAL::Provider is abstract - use a subclass'); | ||
| 58 | } | ||
| 59 | |||
| 60 | =back | ||
| 61 | |||
| 62 | =head1 COPYRIGHT | ||
| 63 | |||
| 64 | Written by Tom Insam, Copyright 2005 Fotango Ltd. All Rights Reserved. | ||
| 65 | |||
| 66 | This program is free software; you can redistribute | ||
| 67 | it and/or modify it under the same terms as Perl itself. | ||
| 68 | |||
| 69 | =head1 BUGS | ||
| 70 | |||
| 71 | None known. Please see L<Template::TAL> for details of how to report bugs. | ||
| 72 | |||
| 73 | =head1 SEE ALSO | ||
| 74 | |||
| 75 | L<Template::TAL>, L<Template::TAL::Provider::Disk> | ||
| 76 | |||
| 77 | =cut | ||
| 78 | |||
| 79 | 1; |