r47830 - in /branches/upstream/libtemplate-provider-fromdata-perl/current: Changes MANIFEST META.yml README lib/Template/Provider/FromDATA.pm t/10-basic.t t/13-cache.t t/14-qualified.t t/15-same_name.t t/lib/My/Other/ t/lib/My/Other/Templates.pm
jawnsy-guest at users.alioth.debian.org
jawnsy-guest at users.alioth.debian.org
Fri Nov 27 03:20:32 UTC 2009
Author: jawnsy-guest
Date: Fri Nov 27 03:20:26 2009
New Revision: 47830
URL: http://svn.debian.org/wsvn/pkg-perl/?sc=1&rev=47830
Log:
[svn-upgrade] Integrating new upstream version, libtemplate-provider-fromdata-perl (0.10)
Added:
branches/upstream/libtemplate-provider-fromdata-perl/current/t/14-qualified.t
branches/upstream/libtemplate-provider-fromdata-perl/current/t/15-same_name.t
branches/upstream/libtemplate-provider-fromdata-perl/current/t/lib/My/Other/
branches/upstream/libtemplate-provider-fromdata-perl/current/t/lib/My/Other/Templates.pm
Modified:
branches/upstream/libtemplate-provider-fromdata-perl/current/Changes
branches/upstream/libtemplate-provider-fromdata-perl/current/MANIFEST
branches/upstream/libtemplate-provider-fromdata-perl/current/META.yml
branches/upstream/libtemplate-provider-fromdata-perl/current/README
branches/upstream/libtemplate-provider-fromdata-perl/current/lib/Template/Provider/FromDATA.pm
branches/upstream/libtemplate-provider-fromdata-perl/current/t/10-basic.t
branches/upstream/libtemplate-provider-fromdata-perl/current/t/13-cache.t
Modified: branches/upstream/libtemplate-provider-fromdata-perl/current/Changes
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libtemplate-provider-fromdata-perl/current/Changes?rev=47830&op=diff
==============================================================================
--- branches/upstream/libtemplate-provider-fromdata-perl/current/Changes (original)
+++ branches/upstream/libtemplate-provider-fromdata-perl/current/Changes Fri Nov 27 03:20:26 2009
@@ -1,4 +1,9 @@
Revision history for Perl extension Template::Provider::FromDATA
+
+0.10 Tue Nov 24 2009
+ - Added the ability to specify a fully qualified template
+ name (Kevin McGrath)
+ - Fix for mod_perl usage (Kevin McGrath)
0.09 Thu Nov 19 2009
- repackaged with a new version of Module::Install
Modified: branches/upstream/libtemplate-provider-fromdata-perl/current/MANIFEST
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libtemplate-provider-fromdata-perl/current/MANIFEST?rev=47830&op=diff
==============================================================================
--- branches/upstream/libtemplate-provider-fromdata-perl/current/MANIFEST (original)
+++ branches/upstream/libtemplate-provider-fromdata-perl/current/MANIFEST Fri Nov 27 03:20:26 2009
@@ -17,7 +17,10 @@
t/11-classes.t
t/12-external_classes.t
t/13-cache.t
+t/14-qualified.t
+t/15-same_name.t
t/20-error.t
t/98-pod_coverage.t
t/99-pod.t
+t/lib/My/Other/Templates.pm
t/lib/My/Templates.pm
Modified: branches/upstream/libtemplate-provider-fromdata-perl/current/META.yml
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libtemplate-provider-fromdata-perl/current/META.yml?rev=47830&op=diff
==============================================================================
--- branches/upstream/libtemplate-provider-fromdata-perl/current/META.yml (original)
+++ branches/upstream/libtemplate-provider-fromdata-perl/current/META.yml Fri Nov 27 03:20:26 2009
@@ -25,4 +25,4 @@
resources:
license: http://dev.perl.org/licenses/
repository: http://github.com/bricas/template-provider-fromdata/tree/master
-version: 0.09
+version: 0.10
Modified: branches/upstream/libtemplate-provider-fromdata-perl/current/README
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libtemplate-provider-fromdata-perl/current/README?rev=47830&op=diff
==============================================================================
--- branches/upstream/libtemplate-provider-fromdata-perl/current/README (original)
+++ branches/upstream/libtemplate-provider-fromdata-perl/current/README Fri Nov 27 03:20:26 2009
@@ -16,6 +16,9 @@
LOAD_TEMPLATES => [ $provider ]
} );
+ # Render a template
+ $template->process( 'mytemplate', { bar => 'Bar' } );
+
# ...and now the templates
__DATA__
@@ -32,7 +35,13 @@
CAVEAT
If you have two templates with the same name, this module will not
- understand the difference, it will simply return the first one found.
+ understand the difference, it will simply return the first one found. If
+ you wish, you can specify a fully qualified template name by prefixing
+ the template with the module name (using "-" instead of "::" as a
+ namespace separator), adding a "/" to separate the module name from the
+ template name.
+
+ $template->process( 'My-Templates/mytemplate', { bar => 'Bar' } );
INSTALLATION
perl Makefile.PL
Modified: branches/upstream/libtemplate-provider-fromdata-perl/current/lib/Template/Provider/FromDATA.pm
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libtemplate-provider-fromdata-perl/current/lib/Template/Provider/FromDATA.pm?rev=47830&op=diff
==============================================================================
--- branches/upstream/libtemplate-provider-fromdata-perl/current/lib/Template/Provider/FromDATA.pm (original)
+++ branches/upstream/libtemplate-provider-fromdata-perl/current/lib/Template/Provider/FromDATA.pm Fri Nov 27 03:20:26 2009
@@ -27,6 +27,9 @@
LOAD_TEMPLATES => [ $provider ]
} );
+ # Render a template
+ $template->process( 'mytemplate', { bar => 'Bar' } );
+
# ...and now the templates
__DATA__
@@ -46,7 +49,12 @@
=head1 CAVEAT
If you have two templates with the same name, this module will not understand
-the difference, it will simply return the first one found.
+the difference, it will simply return the first one found. If you wish, you
+can specify a fully qualified template name by prefixing the template with the
+module name (using C<-> instead of C<::> as a namespace separator), adding
+a C</> to separate the module name from the template name.
+
+ $template->process( 'My-Templates/mytemplate', { bar => 'Bar' } );
=head1 INSTALLATION
@@ -59,7 +67,7 @@
__PACKAGE__->mk_accessors( qw( cache classes ) );
-our $VERSION = '0.09';
+our $VERSION = '0.10';
=head1 METHODS
@@ -134,6 +142,14 @@
my $classes = $self->classes;
my( $content, $error );
+ # handle fully qualified names
+ if( $name =~ m{/} ) {
+ my( $class, $template ) = split( m{/}, $name, 2 );
+ $class =~ s{-}{::}g;
+ $classes = [ $class ];
+ $name = $template;
+ }
+
for my $class ( @$classes ) {
$content = $self->get_file( $class, $name );
last if $content;
@@ -165,32 +181,32 @@
my( $self, $class, $template ) = @_;
my $cache = $self->cache;
-
- if( !exists $cache->{ templates }->{ $template } ) {
- unless ( $cache->{ classes }->{ $class } ) {
- local $/;
- no strict 'refs';
- my $fh = \*{"${class}\::DATA"};
- my $filecache = <$fh>;
- $cache->{ classes }->{ $class }++;
-
- my $result;
- my @files = split /^__(.+)__\r?\n/m, $filecache;
- shift @files;
- while (@files) {
- my( $name, $content ) = splice @files, 0, 2;
- $cache->{ templates }->{ $name } = $content;
- $result = $content if $name eq $template;
- }
-
- return $result;
- }
-
- return undef;
- }
- else {
- return $cache->{ templates }->{ $template };
- }
+ my $key = "${class}/${template}";
+
+ if( exists $cache->{ templates }->{ $key } ) {
+ return $cache->{ templates }->{ $key };
+ }
+
+ return undef if $cache->{ classes }->{ $class };
+
+ no strict 'refs';
+ my $fh = \*{"${class}\::DATA"};
+ my $pos = tell( $fh );
+ my $filecache = do { local $/; <$fh>; };
+ seek( $fh, $pos, 0 );
+ $cache->{ classes }->{ $class }++;
+
+ my $result;
+ my @files = split /^__(.+)__\r?\n/m, $filecache;
+ shift @files;
+ while (@files) {
+ my( $name, $content ) = splice @files, 0, 2;
+ my $key = "${class}/${name}";
+ $cache->{ templates }->{ $key } = $content;
+ $result = $content if $name eq $template;
+ }
+
+ return $result;
}
=head1 AUTHOR
Modified: branches/upstream/libtemplate-provider-fromdata-perl/current/t/10-basic.t
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libtemplate-provider-fromdata-perl/current/t/10-basic.t?rev=47830&op=diff
==============================================================================
--- branches/upstream/libtemplate-provider-fromdata-perl/current/t/10-basic.t (original)
+++ branches/upstream/libtemplate-provider-fromdata-perl/current/t/10-basic.t Fri Nov 27 03:20:26 2009
@@ -5,8 +5,6 @@
use_ok( 'Template' );
use_ok( 'Template::Provider::FromDATA' );
-
-use Template::Constants qw( :debug );
my $provider = Template::Provider::FromDATA->new;
isa_ok( $provider, 'Template::Provider::FromDATA' );
Modified: branches/upstream/libtemplate-provider-fromdata-perl/current/t/13-cache.t
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libtemplate-provider-fromdata-perl/current/t/13-cache.t?rev=47830&op=diff
==============================================================================
--- branches/upstream/libtemplate-provider-fromdata-perl/current/t/13-cache.t (original)
+++ branches/upstream/libtemplate-provider-fromdata-perl/current/t/13-cache.t Fri Nov 27 03:20:26 2009
@@ -6,14 +6,11 @@
use_ok( 'Template' );
use_ok( 'Template::Provider::FromDATA' );
-use Template::Constants qw( :debug );
-
my $provider = Template::Provider::FromDATA->new;
isa_ok( $provider, 'Template::Provider::FromDATA' );
my $template = Template->new( {
LOAD_TEMPLATES => [ $provider ],
-# DEBUG => DEBUG_ALL
} );
isa_ok( $template, 'Template' );
Added: branches/upstream/libtemplate-provider-fromdata-perl/current/t/14-qualified.t
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libtemplate-provider-fromdata-perl/current/t/14-qualified.t?rev=47830&op=file
==============================================================================
--- branches/upstream/libtemplate-provider-fromdata-perl/current/t/14-qualified.t (added)
+++ branches/upstream/libtemplate-provider-fromdata-perl/current/t/14-qualified.t Fri Nov 27 03:20:26 2009
@@ -1,0 +1,25 @@
+use Test::More tests => 5;
+
+use strict;
+use warnings;
+
+use lib qw( t/lib );
+
+use_ok( 'Template' );
+use_ok( 'Template::Provider::FromDATA' );
+
+my $provider = Template::Provider::FromDATA->new( {
+ CLASSES => 'My::Templates'
+} );
+isa_ok( $provider, 'Template::Provider::FromDATA' );
+
+my $template = Template->new( {
+ LOAD_TEMPLATES => [ $provider ],
+} );
+isa_ok( $template, 'Template' );
+
+{
+ my $output;
+ $template->process( 'My-Templates/test', {}, \$output );
+ is( $output, "template data\n" );
+}
Added: branches/upstream/libtemplate-provider-fromdata-perl/current/t/15-same_name.t
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libtemplate-provider-fromdata-perl/current/t/15-same_name.t?rev=47830&op=file
==============================================================================
--- branches/upstream/libtemplate-provider-fromdata-perl/current/t/15-same_name.t (added)
+++ branches/upstream/libtemplate-provider-fromdata-perl/current/t/15-same_name.t Fri Nov 27 03:20:26 2009
@@ -1,0 +1,31 @@
+use Test::More tests => 6;
+
+use strict;
+use warnings;
+
+use lib 't/lib';
+
+use_ok( 'Template' );
+use_ok( 'Template::Provider::FromDATA' );
+
+my $provider = Template::Provider::FromDATA->new( {
+ CLASSES => [ 'My::Templates', 'My::Other::Templates' ]
+} );
+isa_ok( $provider, 'Template::Provider::FromDATA' );
+
+my $template = Template->new( {
+ LOAD_TEMPLATES => [ $provider ],
+} );
+isa_ok( $template, 'Template' );
+
+{ # non-qualified
+ my $output;
+ $template->process( 'test', {}, \$output );
+ is( $output, "template data\n" );
+}
+
+{ # qualified
+ my $output;
+ $template->process( 'My-Other-Templates/test', {}, \$output );
+ is( $output, "other template data\n" );
+}
Added: branches/upstream/libtemplate-provider-fromdata-perl/current/t/lib/My/Other/Templates.pm
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libtemplate-provider-fromdata-perl/current/t/lib/My/Other/Templates.pm?rev=47830&op=file
==============================================================================
--- branches/upstream/libtemplate-provider-fromdata-perl/current/t/lib/My/Other/Templates.pm (added)
+++ branches/upstream/libtemplate-provider-fromdata-perl/current/t/lib/My/Other/Templates.pm Fri Nov 27 03:20:26 2009
@@ -1,0 +1,8 @@
+package My::Other::Templates;
+
+1;
+
+__DATA__
+
+__test__
+other template data
More information about the Pkg-perl-cvs-commits
mailing list