r46677 - in /branches/upstream/libtemplate-declare-perl/current: Changes MANIFEST SIGNATURE lib/Template/Declare.pm lib/Template/Declare/TagSet.pm lib/Template/Declare/Tags.pm t/strict.t

gregoa at users.alioth.debian.org gregoa at users.alioth.debian.org
Mon Nov 2 22:13:50 UTC 2009


Author: gregoa
Date: Mon Nov  2 22:13:45 2009
New Revision: 46677

URL: http://svn.debian.org/wsvn/pkg-perl/?sc=1&rev=46677
Log:
[svn-upgrade] Integrating new upstream version, libtemplate-declare-perl (0.42)

Added:
    branches/upstream/libtemplate-declare-perl/current/t/strict.t
Modified:
    branches/upstream/libtemplate-declare-perl/current/Changes
    branches/upstream/libtemplate-declare-perl/current/MANIFEST
    branches/upstream/libtemplate-declare-perl/current/SIGNATURE
    branches/upstream/libtemplate-declare-perl/current/lib/Template/Declare.pm
    branches/upstream/libtemplate-declare-perl/current/lib/Template/Declare/TagSet.pm
    branches/upstream/libtemplate-declare-perl/current/lib/Template/Declare/Tags.pm

Modified: branches/upstream/libtemplate-declare-perl/current/Changes
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libtemplate-declare-perl/current/Changes?rev=46677&op=diff
==============================================================================
--- branches/upstream/libtemplate-declare-perl/current/Changes (original)
+++ branches/upstream/libtemplate-declare-perl/current/Changes Mon Nov  2 22:13:45 2009
@@ -1,3 +1,7 @@
+0.42 2009-11-01
+* Added the "strict" attribute to make exceptional situations fatal. (Theory)
+* Removed unused "implementor" attribute in Template::Declare::TagSet. (Theory)
+
 0.41 2009-10-29
 * Documentation tweaks (Theory)
 

Modified: branches/upstream/libtemplate-declare-perl/current/MANIFEST
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libtemplate-declare-perl/current/MANIFEST?rev=46677&op=diff
==============================================================================
--- branches/upstream/libtemplate-declare-perl/current/MANIFEST (original)
+++ branches/upstream/libtemplate-declare-perl/current/MANIFEST Mon Nov  2 22:13:45 2009
@@ -61,6 +61,7 @@
 t/siblings.t
 t/similar-aliases.t
 t/smart_tag_wrapper.t
+t/strict.t
 t/subclassing.t
 t/subtemplates.t
 t/tag_sub_list.t

Modified: branches/upstream/libtemplate-declare-perl/current/SIGNATURE
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libtemplate-declare-perl/current/SIGNATURE?rev=46677&op=diff
==============================================================================
--- branches/upstream/libtemplate-declare-perl/current/SIGNATURE (original)
+++ branches/upstream/libtemplate-declare-perl/current/SIGNATURE Mon Nov  2 22:13:45 2009
@@ -14,8 +14,8 @@
 -----BEGIN PGP SIGNED MESSAGE-----
 Hash: SHA1
 
-SHA1 b0a4d3b5bacd1c1ae7022f77379f704c42f04f86 Changes
-SHA1 1bab0077b133b2d3cdd4d66ef63dafa3ef4adf67 MANIFEST
+SHA1 7cff9cc5fac2ce5a6a95ef53b1a7eec956e38cef Changes
+SHA1 a5d3db06dc839282824ffa638a6cfe2ffdee78a9 MANIFEST
 SHA1 6c79a8c5140fc8b0146fbc8f77acc613797eeb6f MANIFEST.SKIP
 SHA1 ab968279525d26d23e4bf76e3d15e4951f87996f META.yml
 SHA1 ee899bc436e17646223925d431d3e9727c1254d1 Makefile.PL
@@ -31,14 +31,14 @@
 SHA1 bd988ba3fb7eee0ad889eadc2f5338a8d98fc2a3 inc/Module/Install/Metadata.pm
 SHA1 e9aa83f3e8b16ccfce544a90a57b63b70a497759 inc/Module/Install/Win32.pm
 SHA1 ade2ac0b0246d4d8e28fa46942e53f6925abda46 inc/Module/Install/WriteAll.pm
-SHA1 01bc4e1b5e6731544a07ddebbefb995f0c7ace20 lib/Template/Declare.pm
+SHA1 bd3aacdeeec829929f7f9ab7c669510b6e315266 lib/Template/Declare.pm
 SHA1 4202a05659532bea1d800bc7296d9c1312624f9b lib/Template/Declare/Buffer.pm
-SHA1 2794aeecd4d243899d80881376502e5444664e55 lib/Template/Declare/TagSet.pm
+SHA1 c86b1e4749f76137c854358f496e8a8030d39fe7 lib/Template/Declare/TagSet.pm
 SHA1 bd39d582e69e0725124a0ffcee10c5d12a2377b3 lib/Template/Declare/TagSet/HTML.pm
 SHA1 c1703c1f999d27878117e0aaf59dcae1d9d98645 lib/Template/Declare/TagSet/RDF.pm
 SHA1 8ba58a5c640010febb799bb03b7857eda34c86bc lib/Template/Declare/TagSet/RDF/EM.pm
 SHA1 2941a453d2627e0c0c02b8f50e7600c648867831 lib/Template/Declare/TagSet/XUL.pm
-SHA1 c64560b8308421deffdc124d87d2f27f2c0b35d9 lib/Template/Declare/Tags.pm
+SHA1 f12037ad41f686043f0bfbb8e7a8ad643424b072 lib/Template/Declare/Tags.pm
 SHA1 238e8999db8b1a8221dcac8afbf0c60448670974 t/99-pod-coverage.t
 SHA1 bb0da54f2b3f2d7955baa41ee458cb3d1887f475 t/99-pod.t
 SHA1 8de6d59c7ed7c771f9cdc5e2dbaef0c31c7ab439 t/MyTagSet.pm
@@ -76,6 +76,7 @@
 SHA1 771c903ee077531f0829b9d4efda1ca4fbd2fdfd t/siblings.t
 SHA1 31a78875cd464b5b2c21cee53c5498c97c395ebb t/similar-aliases.t
 SHA1 fe981469874ceb8b32100e82559d5eea14db3259 t/smart_tag_wrapper.t
+SHA1 3827af507d9d6f29c64be94d1444d6c146ece611 t/strict.t
 SHA1 5a4d6002efea9daf71d3d291bf2a35751a51cba8 t/subclassing.t
 SHA1 679b39abb4812ca1c61ad9e9dd3f5aab97f8829c t/subtemplates.t
 SHA1 44f81200ec38ebf8bc9c836e34942f70990e7207 t/tag_sub_list.t
@@ -92,7 +93,7 @@
 -----BEGIN PGP SIGNATURE-----
 Version: GnuPG v1.4.7 (Darwin)
 
-iD8DBQFK6eivsxfQtHhyRPoRApQpAJ9ed3HQZaHJpNJqx7Q4FAQfIZQMVACePkQ2
-yDQgnPWhv7oNpYKl/cMI/M4=
-=HEfH
+iD8DBQFK7fTjsxfQtHhyRPoRAoS6AJ4tPTryahUgXsB7i655g8PN6YVF3QCeKeVK
+04wL4T14yJ+WzU5iR0ILz+o=
+=oL96
 -----END PGP SIGNATURE-----

Modified: branches/upstream/libtemplate-declare-perl/current/lib/Template/Declare.pm
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libtemplate-declare-perl/current/lib/Template/Declare.pm?rev=46677&op=diff
==============================================================================
--- branches/upstream/libtemplate-declare-perl/current/lib/Template/Declare.pm (original)
+++ branches/upstream/libtemplate-declare-perl/current/lib/Template/Declare.pm Mon Nov  2 22:13:45 2009
@@ -7,11 +7,12 @@
 use Class::ISA;
 use String::BufferStack;
 
-our $VERSION = '0.41';
+our $VERSION = '0.42';
 
 use base 'Class::Data::Inheritable';
 __PACKAGE__->mk_classdata('dispatch_to');
 __PACKAGE__->mk_classdata('postprocessor');
+__PACKAGE__->mk_classdata('strict');
 __PACKAGE__->mk_classdata('templates');
 __PACKAGE__->mk_classdata('private_templates');
 __PACKAGE__->mk_classdata('buffer');
@@ -473,6 +474,7 @@
     Template::Declare->init(
         dispatch_to   => ['MyApp::Templates'],
         postprocessor => \&emphasize,
+        strict        => 1,
     );
 
     print Template::Declare->show( 'before' );
@@ -1056,6 +1058,12 @@
         warn "Rendering $path took " . (time - $start) . " seconds.";
     });
 
+=item strict
+
+Die in exceptional situations, such as when a template can't be found, rather
+than just warn. False by default for backward compatibility. The default may
+be changed in the future, so specifying the value explicitly is recommended.
+
 =back
 
 =cut
@@ -1064,20 +1072,15 @@
     my $class = shift;
     my %args  = (@_);
 
-    if ( $args{'dispatch_to'} ) {
-        $class->dispatch_to( $args{'dispatch_to'} );
-    } elsif ( $args{'roots'} ) {
-        $class->roots( $args{'roots'} );
+    if ( $args{dispatch_to} ) {
+        $class->dispatch_to( $args{dispatch_to} );
+    } elsif ( $args{roots} ) {
+        $class->roots( $args{roots} );
     }
 
-    if ( $args{'postprocessor'} ) {
-        $class->postprocessor( $args{'postprocessor'} );
-    }
-
-    if ( $args{'around_template'} ) {
-        $class->around_template( $args{'around_template'} );
-    }
-
+    $class->strict( $args{strict} ) if exists $args{strict};
+    $class->postprocessor( $args{postprocessor} ) if $args{postprocessor};
+    $class->around_template( $args{around_template} ) if $args{around_template};
 }
 
 =head2 show TEMPLATE_NAME

Modified: branches/upstream/libtemplate-declare-perl/current/lib/Template/Declare/TagSet.pm
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libtemplate-declare-perl/current/lib/Template/Declare/TagSet.pm?rev=46677&op=diff
==============================================================================
--- branches/upstream/libtemplate-declare-perl/current/lib/Template/Declare/TagSet.pm (original)
+++ branches/upstream/libtemplate-declare-perl/current/lib/Template/Declare/TagSet.pm Mon Nov  2 22:13:45 2009
@@ -5,7 +5,7 @@
 use base qw(Class::Accessor::Fast);
 
 __PACKAGE__->mk_ro_accessors(
-    qw{ namespace package implementor }
+    qw{ namespace package }
 );
 
 sub get_alternate_spelling {

Modified: branches/upstream/libtemplate-declare-perl/current/lib/Template/Declare/Tags.pm
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libtemplate-declare-perl/current/lib/Template/Declare/Tags.pm?rev=46677&op=diff
==============================================================================
--- branches/upstream/libtemplate-declare-perl/current/lib/Template/Declare/Tags.pm (original)
+++ branches/upstream/libtemplate-declare-perl/current/lib/Template/Declare/Tags.pm Mon Nov  2 22:13:45 2009
@@ -6,7 +6,7 @@
 
 package Template::Declare::Tags;
 
-our $VERSION = '0.41';
+our $VERSION = '0.42';
 
 use Template::Declare;
 use base 'Exporter';
@@ -465,8 +465,9 @@
 
         if ( lc($key) eq 'id' ) {
             if ( $ELEMENT_ID_CACHE{$val}++ ) {
-                warn
-                    "HTML appears to contain illegal duplicate element id: $val";
+                my $msg = "HTML appears to contain illegal duplicate element id: $val";
+                die $msg if Template::Declare->strict;
+                warn $msg;
             }
         }
 
@@ -866,6 +867,7 @@
     unless ($callable) {
         my $msg = "The template '$template' could not be found";
         $msg .= " (it might be private)" if !$inside_template;
+        croak $msg if Template::Declare->strict;
         carp $msg;
         return '';
     }

Added: branches/upstream/libtemplate-declare-perl/current/t/strict.t
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libtemplate-declare-perl/current/t/strict.t?rev=46677&op=file
==============================================================================
--- branches/upstream/libtemplate-declare-perl/current/t/strict.t (added)
+++ branches/upstream/libtemplate-declare-perl/current/t/strict.t Mon Nov  2 22:13:45 2009
@@ -1,0 +1,58 @@
+use warnings;
+use strict;
+
+package Wifty::UI;
+use base qw/Template::Declare/;
+use Template::Declare::Tags;
+
+template oops => sub {
+    with( id => 'foo', id => 'foo' ), html {
+    };
+};
+
+package main;
+
+use Test::More tests => 11;
+use Test::Warn;
+
+##############################################################################
+Template::Declare->init(dispatch_to => ['Wifty::UI']);
+pass 'Init with no strict setting';
+
+warning_like { Template::Declare->show('nonesuch' ) }
+    qr/The template 'nonesuch' could not be found [(]it might be private[)]/,
+    'Should get warning for nonexistent template';
+
+warning_like { Template::Declare->show('oops' ) }
+    qr/HTML appears to contain illegal duplicate element id: foo/,
+    'Should get warning for duplicate "id" attribute';
+
+##############################################################################
+Template::Declare->init(dispatch_to => ['Wifty::UI'], strict => 0);
+pass 'Init with strict off';
+
+warning_like { Template::Declare->show('nonesuch' ) }
+    qr/The template 'nonesuch' could not be found [(]it might be private[)]/,
+    'Should still get warning for nonexistent template';
+
+warning_like { Template::Declare->show('oops' ) }
+    qr/HTML appears to contain illegal duplicate element id: foo/,
+    'Should still get warning for duplicate "id" attribute';
+
+##############################################################################
+Template::Declare->init(dispatch_to => ['Wifty::UI'], strict => 1);
+pass 'Init with strict on';
+
+undef $@;
+eval { Template::Declare->show('nonesuch' ) };
+ok my $err = $@, 'Should get exception for missing template';
+like $err,
+    qr/The template 'nonesuch' could not be found [(]it might be private[)]/,
+    '... and it should be about nonexistent template';
+
+undef $@;
+eval { Template::Declare->show('oops' ) };
+ok my $err = $@, 'Should get exception for duplicate "id"';
+like $err,
+    qr/HTML appears to contain illegal duplicate element id: foo/,
+    '... and it should be about the duplicate "id" attribute';




More information about the Pkg-perl-cvs-commits mailing list