[Jifty-commit] r2394 - in Template-Declare: lib/Template
lib/Template/Declare t
jifty-commit at lists.jifty.org
jifty-commit at lists.jifty.org
Sat Dec 16 22:48:11 EST 2006
Author: jesse
Date: Sat Dec 16 22:48:10 2006
New Revision: 2394
Modified:
Template-Declare/ (props changed)
Template-Declare/lib/Template/Declare.pm
Template-Declare/lib/Template/Declare/Tags.pm
Template-Declare/t/arg-declaration-styles.t
Template-Declare/t/indexhtml.t
Template-Declare/t/private.t
Template-Declare/t/subtemplates.t
Template-Declare/t/trivial.t
Log:
r46220 at pinglin: jesse | 2006-12-16 21:18:51 -0500
* tests converted to use the ->init method.
Modified: Template-Declare/lib/Template/Declare.pm
==============================================================================
--- Template-Declare/lib/Template/Declare.pm (original)
+++ Template-Declare/lib/Template/Declare.pm Sat Dec 16 22:48:10 2006
@@ -5,7 +5,9 @@
use base 'Class::Data::Inheritable';
-__PACKAGE__->mk_classdata('template_packages');
+__PACKAGE__->mk_classdata('roots');
+
+__PACKAGE__->roots([]);
$Template::Declare::VERSION = "0.00_01";
@@ -33,6 +35,29 @@
=cut
+=head2 init
+
+This I<class method> initialize the C<Template::Declare> system.
+
+=over
+
+=item roots
+
+=back
+
+=cut
+
+sub init {
+ my $class = shift;
+ my %args = (@_);
+
+ if ($args{'roots'}) {
+ $class->roots($args{'roots'});
+ }
+
+}
+
+
=head2 has_template
=cut
@@ -50,14 +75,17 @@
my $template_name = shift;
my $show_private = shift;
- if ( my $coderef = $self->can( _template_name_to_sub($template_name) ) ) {
+ foreach my $package (@{Template::Declare->roots}) {
+
+
+ if ( my $coderef = $package->can( _template_name_to_sub($template_name) ) ) {
return $coderef;
}
elsif ($show_private) {
- return $self->can( _template_name_to_private_sub($template_name) );
+ return $package->can( _template_name_to_private_sub($template_name) );
+ }
}
-
}
sub _template_name_to_sub {
Modified: Template-Declare/lib/Template/Declare/Tags.pm
==============================================================================
--- Template-Declare/lib/Template/Declare/Tags.pm (original)
+++ Template-Declare/lib/Template/Declare/Tags.pm Sat Dec 16 22:48:10 2006
@@ -52,9 +52,7 @@
if (wantarray) {
return ( $template_class, $template_name, $codesub );
} else {
- *{ $template_class . '::'
- . Template::Declare::_template_name_to_sub($template_name); }
- = $codesub;
+ *{ $template_class . '::' . Template::Declare::_template_name_to_sub($template_name); } = $codesub;
}
}
@@ -261,7 +259,7 @@
$callable = $template;
} else {
# if we're inside a template, we should show private templates
- $callable = $self->has_template( $template, $INSIDE_TEMPLATE );
+ $callable = Template::Declare->has_template( $template, $INSIDE_TEMPLATE );
}
# may want to just use the return value of has_template eventually
Modified: Template-Declare/t/arg-declaration-styles.t
==============================================================================
--- Template-Declare/t/arg-declaration-styles.t (original)
+++ Template-Declare/t/arg-declaration-styles.t Sat Dec 16 22:48:10 2006
@@ -63,13 +63,10 @@
}
};
-package Template::Declare::Tags;
use Test::More tests => 39;
use HTML::Lint;
-our $self;
-local $self = {};
-bless $self, 'TestApp::UI';
+Template::Declare->init(roots => ['TestApp::UI']);
for (qw(content content_curly content_explicit)) {
local $Template::Declare::Tags::BUFFER;
Modified: Template-Declare/t/indexhtml.t
==============================================================================
--- Template-Declare/t/indexhtml.t (original)
+++ Template-Declare/t/indexhtml.t Sat Dec 16 22:48:10 2006
@@ -35,14 +35,13 @@
};
-package Template::Declare::Tags;
use Test::More qw/no_plan/;
use HTML::Lint;
+Template::Declare->init(roots => ['Wifty::UI']);
+
+
-our $self;
-local $self = {};
-bless $self, 'Wifty::UI';
for('index.html', 'dash-test'){
{
Modified: Template-Declare/t/private.t
==============================================================================
--- Template-Declare/t/private.t (original)
+++ Template-Declare/t/private.t Sat Dec 16 22:48:10 2006
@@ -21,14 +21,14 @@
};
-package Template::Declare::Tags;
+
+package main;
+use Template::Declare::Tags;
+Template::Declare->init(roots => ['Wifty::UI']);
use Test::More qw/no_plan/;
use HTML::Lint;
-our $self;
-local $self = {};
-bless $self, 'Wifty::UI';
{
local $Template::Declare::Tags::BUFFER;
my $simple = ( show('simple') );
Modified: Template-Declare/t/subtemplates.t
==============================================================================
--- Template-Declare/t/subtemplates.t (original)
+++ Template-Declare/t/subtemplates.t Sat Dec 16 22:48:10 2006
@@ -25,14 +25,13 @@
};
-package Template::Declare::Tags;
use Test::More qw/no_plan/;
use HTML::Lint;
-our $self;
-local $self = {};
-bless $self, 'Wifty::UI';
+Template::Declare->init(roots => ['Wifty::UI']);
+
+
{
local $Template::Declare::Tags::BUFFER;
my $simple =(show('my/content'));
Modified: Template-Declare/t/trivial.t
==============================================================================
--- Template-Declare/t/trivial.t (original)
+++ Template-Declare/t/trivial.t Sat Dec 16 22:48:10 2006
@@ -143,6 +143,9 @@
our $self;
local $self = {};
bless $self, 'Wifty::UI';
+
+Template::Declare->init( roots => ['Wifty::UI']);
+
{
local $Template::Declare::Tags::BUFFER;
my $simple =(show('simple'));
More information about the Jifty-commit
mailing list