Commit 8dd14b7c authored by gregor herrmann's avatar gregor herrmann

[svn-upgrade] Integrating new upstream version, libtemplate-declare-perl (0.42)

parent 4dd434e0
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)
......
......@@ -61,6 +61,7 @@ t/self.t
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
......
......@@ -14,8 +14,8 @@ not run its Makefile.PL or Build.PL.
-----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 9f6beaa2f4749ceb5dd0c9b0c647d0f3289c7b46 inc/Module/Install/Makefile.pm
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 dad25f5c714947cf7fb5954fb876b18114c43ed5 t/self.t
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 @@ SHA1 7bdcccbdd5253f4eae12d3c279183e10577a0184 t/xss.t
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.7 (Darwin)
iD8DBQFK6eivsxfQtHhyRPoRApQpAJ9ed3HQZaHJpNJqx7Q4FAQfIZQMVACePkQ2
yDQgnPWhv7oNpYKl/cMI/M4=
=HEfH
iD8DBQFK7fTjsxfQtHhyRPoRAoS6AJ4tPTryahUgXsB7i655g8PN6YVF3QCeKeVK
04wL4T14yJ+WzU5iR0ILz+o=
=oL96
-----END PGP SIGNATURE-----
......@@ -7,11 +7,12 @@ use Template::Declare::Buffer;
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 @@ Now let's have a look at how we use these templates with a post-processor:
Template::Declare->init(
dispatch_to => ['MyApp::Templates'],
postprocessor => \&emphasize,
strict => 1,
);
print Template::Declare->show( 'before' );
......@@ -1056,6 +1058,12 @@ of the template itself. You can use this for instrumentation. For example:
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 @@ sub init {
my $class = shift;
my %args = (@_);
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'} );
if ( $args{dispatch_to} ) {
$class->dispatch_to( $args{dispatch_to} );
} elsif ( $args{roots} ) {
$class->roots( $args{roots} );
}
$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
......
......@@ -5,7 +5,7 @@ use warnings;
use base qw(Class::Accessor::Fast);
__PACKAGE__->mk_ro_accessors(
qw{ namespace package implementor }
qw{ namespace package }
);
sub get_alternate_spelling {
......
......@@ -6,7 +6,7 @@ use strict;
package Template::Declare::Tags;
our $VERSION = '0.41';
our $VERSION = '0.42';
use Template::Declare;
use base 'Exporter';
......@@ -465,8 +465,9 @@ sub with (@) {
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 @@ sub _show_template {
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 '';
}
......
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';
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment