| 1 | package Jifty::View::Declare; | ||
| 2 | |||
| 3 | |||
| 4 | use strict; | ||
| 5 | use warnings; | ||
| 6 | use constant BaseClassName => 'Jifty::View::Declare::BaseClass'; | ||
| 7 | |||
| 8 | =head1 NAME | ||
| 9 | |||
| 10 | Jifty::View::Declare - Build views using Template::Declare | ||
| 11 | |||
| 12 | =head1 SYNOPSIS | ||
| 13 | |||
| 14 | package MyApp::View; | ||
| 15 | use Jifty::View::Declare -base; | ||
| 16 | |||
| 17 | template 'index.html' => page { | ||
| 18 | { title is 'Some Title' } | ||
| 19 | b { "The Index" }; | ||
| 20 | }; | ||
| 21 | |||
| 22 | =head1 DESCRIPTION | ||
| 23 | |||
| 24 | L<Template::Declare> is a templating system using a declarative syntax built on top of Perl. This provides a templating language built in a similar style to the dispatcher language in L<Jifty::Dispatcher>, the model language in L<Jifty::DBI::Schema>, and the action language in L<Jifty::Param::Schema>. | ||
| 25 | |||
| 26 | To use this view system, you must declare a class named C<MyApp::View> (where I<MyApp> is the name of your Jifty application). Use this library class to bring in all the details needed to make it work: | ||
| 27 | |||
| 28 | package MyApp::View; | ||
| 29 | use Jifty::View::Declare -base; | ||
| 30 | |||
| 31 | # Your code... | ||
| 32 | |||
| 33 | For more details on how to write the individual templates, see L<Template::Declare> and also L<Jifty::View::Declare::Helpers> for Jifty specific details. | ||
| 34 | |||
| 35 | =cut | ||
| 36 | |||
| 37 | sub import { | ||
| 38 | my ($class, $import) = @_; | ||
| 39 | ($import and $import eq '-base') or return; | ||
| 40 | no strict 'refs'; | ||
| 41 | my $pkg = caller; | ||
| 42 | Jifty::Util->require(BaseClassName); | ||
| 43 | push @{ $pkg . '::ISA' }, BaseClassName; | ||
| 44 | |||
| 45 | strict->import; | ||
| 46 | warnings->import; | ||
| 47 | |||
| 48 | @_ = BaseClassName; | ||
| 49 | goto &{BaseClassName()->can('import')}; | ||
| 50 | } | ||
| 51 | |||
| 52 | =head1 SEE ALSO | ||
| 53 | |||
| 54 | L<Jifty::View::Declare::Helpers>, L<Template::Declare> | ||
| 55 | |||
| 56 | =head1 LICENSE | ||
| 57 | |||
| 58 | Jifty is Copyright 2005-2010 Best Practical Solutions, LLC. | ||
| 59 | Jifty is distributed under the same terms as Perl itself. | ||
| 60 | |||
| 61 | =cut | ||
| 62 | |||
| 63 | 1; |