[Jifty-commit] r5088 - in Template-Declare: lib/Template
Jifty commits
jifty-commit at lists.jifty.org
Sun Feb 10 18:00:01 EST 2008
Author: sartak
Date: Sun Feb 10 18:00:00 2008
New Revision: 5088
Modified:
Template-Declare/ (props changed)
Template-Declare/lib/Template/Declare.pm
Log:
r51707 at onn: sartak | 2008-02-10 17:59:56 -0500
Add a simplistic example for inheritance
Modified: Template-Declare/lib/Template/Declare.pm
==============================================================================
--- Template-Declare/lib/Template/Declare.pm (original)
+++ Template-Declare/lib/Template/Declare.pm Sun Feb 10 18:00:00 2008
@@ -263,12 +263,38 @@
# <h1>Welcome to <em>my</em> site. It's <em>great</em>!</h1>
# <h2>This is _not_ emphasized.</h2>
-=head2 Multiple template roots (search paths)
-
=head2 Inheritance
+Templates are really just methods. You can subclass your template packages
+to override some of those methods. See also L<Jifty::View::Declare::CRUD>.
+
+ package MyApp::Templates::GenericItem;
+ use Template::Declare::Tags;
+ use base 'Template::Declare';
+
+ template 'list' => sub {
+ div {
+ show('item', $_) for @_;
+ }
+ };
+ template 'item' => sub {
+ span { shift }
+ };
+
+ package MyApp::Templates::BlogPost;
+ use Template::Declare::Tags;
+ use base 'MyApp::Templates::GenericItem';
+
+ template 'item' => sub {
+ my $post = shift;
+ h1 { $post->title }
+ div { $post->body }
+ };
+
=head2 Aliasing
+=head2 Multiple template roots (search paths)
+
=head1 METHODS
=head2 init
More information about the Jifty-commit
mailing list