r21752 - in /branches/upstream/libpetal-perl/current: ./ lib/ lib/Petal/ lib/Petal/Hash/ lib/Petal/TranslationService/ t/ t/data/
gregoa at users.alioth.debian.org
gregoa at users.alioth.debian.org
Mon Jun 16 18:57:31 UTC 2008
Author: gregoa
Date: Mon Jun 16 18:57:31 2008
New Revision: 21752
URL: http://svn.debian.org/wsvn/?sc=1&rev=21752
Log:
[svn-upgrade] Integrating new upstream version, libpetal-perl (2.19)
Added:
branches/upstream/libpetal-perl/current/t/094_notfalse.t
branches/upstream/libpetal-perl/current/t/096_oddeven.t
branches/upstream/libpetal-perl/current/t/097_cache_only.t
branches/upstream/libpetal-perl/current/t/098_multiple-attributes.t
branches/upstream/libpetal-perl/current/t/data/multiple-attributes.xml
branches/upstream/libpetal-perl/current/t/data/notfalse.xml
branches/upstream/libpetal-perl/current/t/data/oddeven.xml
Modified:
branches/upstream/libpetal-perl/current/Changes
branches/upstream/libpetal-perl/current/MANIFEST
branches/upstream/libpetal-perl/current/META.yml
branches/upstream/libpetal-perl/current/Makefile.PL
branches/upstream/libpetal-perl/current/lib/Petal.pm
branches/upstream/libpetal-perl/current/lib/Petal/Cookbook.pod
branches/upstream/libpetal-perl/current/lib/Petal/Hash.pm
branches/upstream/libpetal-perl/current/lib/Petal/Hash/Var.pm
branches/upstream/libpetal-perl/current/lib/Petal/TranslationService/MOFile.pm
branches/upstream/libpetal-perl/current/t/054_Opt_cache.t
Modified: branches/upstream/libpetal-perl/current/Changes
URL: http://svn.debian.org/wsvn/branches/upstream/libpetal-perl/current/Changes?rev=21752&op=diff
==============================================================================
--- branches/upstream/libpetal-perl/current/Changes (original)
+++ branches/upstream/libpetal-perl/current/Changes Mon Jun 16 18:57:31 2008
@@ -1,4 +1,13 @@
Revision history for Petal.
+
+2.19 Fri Jun 16 15:22:00 2006
+ - alias false: modifier as not: to match TALES spec (Jonathan Vanasco)
+ - fix repeat/odd documentation bug and add to cookbook (Jonathan Vanasco)
+ - pod typos (sarabob)
+ - CACHE_ONLY option (Jonathan Vanasco)
+ - Add Digest::MD5 dependency (aaron)
+ - Allow passing arguments to coderefs
+ - Encoding support for gettext mo/po files (Andrew Rodland)
2.18 Tue Jan 17 13:01:00 2006
- $Petal::CodeGenerator::PI_RE should be applied newline insensitively
Modified: branches/upstream/libpetal-perl/current/MANIFEST
URL: http://svn.debian.org/wsvn/branches/upstream/libpetal-perl/current/MANIFEST?rev=21752&op=diff
==============================================================================
--- branches/upstream/libpetal-perl/current/MANIFEST (original)
+++ branches/upstream/libpetal-perl/current/MANIFEST Mon Jun 16 18:57:31 2008
@@ -98,6 +98,10 @@
t/091_attribute-newline.t
t/092_on-error.t
t/093_translate.t
+t/094_notfalse.t
+t/096_oddeven.t
+t/097_cache_only.t
+t/098_multiple-attributes.t
t/benchmark.pl
t/data/access_obj_array.html
t/data/access_obj_hash.html
@@ -168,6 +172,7 @@
t/data/metal_self_include.xml
t/data/metal_use_macro.xml
t/data/method_param.xml
+t/data/multiple-attributes.xml
t/data/multiple_includes/includes/footer.tmpl
t/data/multiple_includes/includes/header.tmpl
t/data/multiple_includes/register_form.tmpl
@@ -176,6 +181,8 @@
t/data/nbsp.html
t/data/nested_modifiers/test1.xml
t/data/nested_modifiers/test2.xml
+t/data/notfalse.xml
+t/data/oddeven.xml
t/data/omit-tag.xml
t/data/pass_variables/attributes.html
t/data/pass_variables/content.html
Modified: branches/upstream/libpetal-perl/current/META.yml
URL: http://svn.debian.org/wsvn/branches/upstream/libpetal-perl/current/META.yml?rev=21752&op=diff
==============================================================================
--- branches/upstream/libpetal-perl/current/META.yml (original)
+++ branches/upstream/libpetal-perl/current/META.yml Mon Jun 16 18:57:31 2008
@@ -1,13 +1,14 @@
# http://module-build.sourceforge.net/META-spec.html
#XXXXXXX This is a prototype!!! It will change in the future!!! XXXXX#
name: Petal
-version: 2.18
+version: 2.19
version_from: lib/Petal.pm
installdirs: site
requires:
+ Digest::MD5:
MKDoc::XML: 0.72
Scalar::Util: 1.07
Test::Harness: 2.00
distribution_type: module
-generated_by: ExtUtils::MakeMaker version 6.17
+generated_by: ExtUtils::MakeMaker version 6.30
Modified: branches/upstream/libpetal-perl/current/Makefile.PL
URL: http://svn.debian.org/wsvn/branches/upstream/libpetal-perl/current/Makefile.PL?rev=21752&op=diff
==============================================================================
--- branches/upstream/libpetal-perl/current/Makefile.PL (original)
+++ branches/upstream/libpetal-perl/current/Makefile.PL Mon Jun 16 18:57:31 2008
@@ -8,6 +8,7 @@
'Test::Harness' => '2.00',
'Scalar::Util' => '1.07',
'MKDoc::XML' => '0.72',
+ 'Digest::MD5' => '',
},
($] >= 5.005 ? ## Add these new keywords supported since 5.005
(ABSTRACT_FROM => 'lib/Petal.pm', # retrieve abstract from module
Modified: branches/upstream/libpetal-perl/current/lib/Petal.pm
URL: http://svn.debian.org/wsvn/branches/upstream/libpetal-perl/current/lib/Petal.pm?rev=21752&op=diff
==============================================================================
--- branches/upstream/libpetal-perl/current/lib/Petal.pm (original)
+++ branches/upstream/libpetal-perl/current/lib/Petal.pm Mon Jun 16 18:57:31 2008
@@ -95,13 +95,17 @@
our $MEMORY_CACHE = 1;
+# cache only mode
+our $CACHE_ONLY = 0;
+
+
# prevents infinites includes...
our $MAX_INCLUDES = 30;
our $CURRENT_INCLUDES = 0;
# this is for CPAN
-our $VERSION = '2.18';
+our $VERSION = '2.19';
# The CodeGenerator class backend to use.
@@ -137,6 +141,7 @@
my $file = shift (@ARGV);
local $Petal::DISK_CACHE = 0;
local $Petal::MEMORY_CACHE = 0;
+ local $Petal::CACHE_ONLY = 0;
local $Petal::INPUT = $ENV{PETAL_INPUT} || 'XML';
local $Petal::OUTPUT = $ENV{PETAL_OUTPUT} || 'XHTML';
print ${Petal->new ($file)->_canonicalize()};
@@ -151,6 +156,7 @@
my $file = shift (@ARGV);
local $Petal::DISK_CACHE = 0;
local $Petal::MEMORY_CACHE = 0;
+ local $Petal::CACHE_ONLY = 0;
print Petal->new ($file)->_code_disk_cached;
}
@@ -163,6 +169,7 @@
my $file = shift (@ARGV);
local $Petal::DISK_CACHE = 0;
local $Petal::MEMORY_CACHE = 0;
+ local $Petal::CACHE_ONLY = 0;
print Petal->new ($file)->_code_with_line_numbers;
}
@@ -241,6 +248,7 @@
sub error_on_undef_var { exists $_[0]->{error_on_undef_var} ? $_[0]->{error_on_undef_var} : $ERROR_ON_UNDEF_VAR }
sub disk_cache { exists $_[0]->{disk_cache} ? $_[0]->{disk_cache} : $DISK_CACHE }
sub memory_cache { exists $_[0]->{memory_cache} ? $_[0]->{memory_cache} : $MEMORY_CACHE }
+sub cache_only { exists $_[0]->{cache_only} ? $_[0]->{cache_only} : $CACHE_ONLY }
sub max_includes { exists $_[0]->{max_includes} ? $_[0]->{max_includes} : $MAX_INCLUDES }
@@ -341,6 +349,7 @@
local $ERROR_ON_UNDEF_VAR = defined $self->{error_on_undef_var} ? $self->{error_on_undef_var} : $ERROR_ON_UNDEF_VAR;
local $DISK_CACHE = defined $self->{disk_cache} ? $self->{disk_cache} : $DISK_CACHE;
local $MEMORY_CACHE = defined $self->{memory_cache} ? $self->{memory_cache} : $MEMORY_CACHE;
+ local $CACHE_ONLY = defined $self->{cache_only} ? $self->{cache_only} : $CACHE_ONLY;
local $MAX_INCLUDES = defined $self->{max_includes} ? $self->{max_includes} : $MAX_INCLUDES;
local $INPUT = defined $self->{input} ? $self->{input} : $INPUT;
local $OUTPUT = defined $self->{output} ? $self->{output} : $OUTPUT;
@@ -369,6 +378,8 @@
die "\$hash is undefined\n\n" unless $hash;
$res = $coderef->($hash);
};
+
+ if ( $CACHE_ONLY == 1 ){ return 1; }
if (defined $@ and $@) { $res = $self->_handle_error ($@) }
elsif (defined $TranslationService && $CURRENT_INCLUDES == 1) { $res = Petal::I18N->process ($res) }
@@ -764,7 +775,7 @@
local $Petal::OUTPUT = 'XHTML';
my $template = new Petal ('foo.xhtml');
- template->process ( my_var => some_object() );
+ $template->process ( my_var => some_object() );
some_object() is a subroutine that returns some kind of object, may it be a scalar,
object, array referebce or hash reference. Let's see what we can do...
@@ -847,11 +858,15 @@
my $template = new Petal ( file => 'hello_world', lang => 'fr-CA' );
print $template->process ( my_var => some_object() );
-What will happen is that the C<$template> object will try to find a file named
-C<fr-CA>, then C<fr>, then will default to <en>. It should work fine for
-includes, too!
-
-NOTE: There is now beta support for ZPT-like i18n attributes, which should
+What will happen is that the C<$template> object will look in the
+C<hello_world> directory and try to find a file named C<fr-CA.xhtml>, then
+C<fr.xhtml>, then will default to C<en.xhtml>. It works fine for includes, too!
+
+These internationalized templates can have whatever file-extension you like,
+Petal searches on the first part of the filename. So you can call them
+C<fr.html>, C<fr.xml>, C<fr.xhtml> or use whatever convention suits you.
+
+NOTE: There is now support for ZPT-like i18n attributes, which should
provide a much nicer framework. See L<Petal::I18N> for details.
@@ -960,6 +975,13 @@
If set to C<false>, Petal will not use the C<Petal::Cache::Memory> module.
+=head2 cache_only => I<true> | I<false> (default: I<false>)
+
+If set to C<true>, Petal will return true after having compiled a template into
+perl code and a subroutine , and optionally using disk_cache or memory_cache if
+either is set.
+
+
=head2 max_includes => I<number> (default: 30)
The maximum number of recursive includes before Petal stops processing. This
@@ -970,7 +992,8 @@
If this option is true, when Petal cannot process a template it will
output lots of debugging information in a temporary file which you can
-inspect.
+inspect. The location for this file is wherever File::Spec->tmpdir()
+specifies as a temp directory (usually /tmp on a unix system).
=head2 encode_charset => I<charset> (default: undef)
@@ -1049,6 +1072,11 @@
<tag tal:repeat="element_name EXPRESSION">
blah blah blah
</tag>
+
+Why?
+
+Repeat statements are used to loop through a list of values,
+typically to display the resulting records of a database query.
Example:
@@ -1079,7 +1107,7 @@
>
<tr
class="odd"
- tal:condition="true: audience/odd"
+ tal:condition="repeat/odd"
>
<td>
This a odd row, it comes before the even row.
@@ -1087,7 +1115,7 @@
</tr>
<tr
class="even"
- tal:condition="true: audience/even"
+ tal:condition="repeat/even"
>
<td>
This a even row.
@@ -1096,11 +1124,38 @@
</div>
</table>
-Why?
-
-Repeat statements are used to loop through a list of values,
-typically to display the resulting records of a database query.
-
+I<repeat> is a local temporary object that only exists within a
+petal:repeat loop. It has a bunch of methods useful for selecting
+different positions in the loop:
+
+=head3 repeat/index
+
+I<index> returns the numeric position of this item within the loop, starts with
+one not zero.
+
+=head3 repeat/number
+
+I<number> is an alias for I<index>.
+
+=head3 repeat/even
+
+I<even> is true if the position is even (0, 2, 4 ...)
+
+=head3 repeat/odd
+
+I<odd> is true is the position is odd (1, 3, 5 ...)
+
+=head3 repeat/start
+
+I<start> is true if this is the first item.
+
+=head3 repeat/end
+
+I<end> is true if this is the last item.
+
+=head3 repeat/inner
+
+I<inner> is true if this is not the I<start> or I<end>.
=head2 attributes
@@ -1696,6 +1751,10 @@
Otherwise, subsequent calls will resume at step 6, until the source template
changes.
+If you are using the mod_perl prefork MPM, you can precompile Petal templates
+into Apache's shared memory at startup by using the cache_only option. This
+will allow you to run through steps 1-7 without passing any data to Petal.
+
=head1 DECRYPTING WARNINGS AND ERRORS
Modified: branches/upstream/libpetal-perl/current/lib/Petal/Cookbook.pod
URL: http://svn.debian.org/wsvn/branches/upstream/libpetal-perl/current/lib/Petal/Cookbook.pod?rev=21752&op=diff
==============================================================================
--- branches/upstream/libpetal-perl/current/lib/Petal/Cookbook.pod (original)
+++ branches/upstream/libpetal-perl/current/lib/Petal/Cookbook.pod Mon Jun 16 18:57:31 2008
@@ -223,6 +223,35 @@
</table>
See L<Petal::Utils|Petal::Utils> for more information.
+
+Alternatively, this can be done entirely with TAL (contributed by Jonathan
+Vanasco):
+
+ <div tal:repeat="row rows">
+ <tag tal:omit-tag="string:1" tal:condition="repeat/even"><tag
+ tal:define="rowClass string:rowEven" tal:omit-tag="string:1"/></tag>
+ <tag tal:omit-tag="string:1" tal:condition="repeat/odd"><tag
+ tal:define="rowClass string:rowOdd" tal:omit-tag="string:1"/></tag>
+ <div
+ tal:attributes="class rowClass"
+ >
+ This will use either the rowEven or rowOdd class. All of the 'tag'
+ elements are omitted on render. This uses a nested define tag in a
+ condition tag, because define precedes condition in order of operations.
+ </div>
+ <div>
+
+The simplest way to do odd/even rows may to duplicate the code entirely for
+each type or row, though this may cause maintenance headaches:
+
+ <table>
+ <tr tal:repeat="emp employees">
+ <td tal:condition="repeat/odd" class="odd" tal:content="emp/name">Employee Name</td>
+ <td tal:condition="repeat/even" class="even" tal:content="emp/name">Employee Name</td>
+ ...
+ </tr>
+ </table>
+
=head1 ADVANCED
Modified: branches/upstream/libpetal-perl/current/lib/Petal/Hash.pm
URL: http://svn.debian.org/wsvn/branches/upstream/libpetal-perl/current/lib/Petal/Hash.pm?rev=21752&op=diff
==============================================================================
--- branches/upstream/libpetal-perl/current/lib/Petal/Hash.pm (original)
+++ branches/upstream/libpetal-perl/current/lib/Petal/Hash.pm Mon Jun 16 18:57:31 2008
@@ -70,6 +70,7 @@
return not $hash->fetch ("true:$variable");
};
+$MODIFIERS->{'not:'} = $MODIFIERS->{'false:'};
# encode: modifier (deprecated stuff)
$MODIFIERS->{'encode:'} = sub {
Modified: branches/upstream/libpetal-perl/current/lib/Petal/Hash/Var.pm
URL: http://svn.debian.org/wsvn/branches/upstream/libpetal-perl/current/lib/Petal/Hash/Var.pm?rev=21752&op=diff
==============================================================================
--- branches/upstream/libpetal-perl/current/lib/Petal/Hash/Var.pm (original)
+++ branches/upstream/libpetal-perl/current/lib/Petal/Hash/Var.pm Mon Jun 16 18:57:31 2008
@@ -96,8 +96,11 @@
elsif (isa ($current, 'HASH'))
{
ACCESS_HASH:
+ unless (isa $current->{$next}, 'CODE')
+ {
confess "Cannot access hash at '$current_path' with parameters (near $argument)"
if ($has_args and not $has_path_tokens);
+ }
$current = $current->{$next};
}
elsif (isa ($current, 'ARRAY'))
@@ -127,7 +130,7 @@
return '';
}
- $current = (isa ($current, 'CODE')) ? $current->() : $current;
+ $current = (isa ($current, 'CODE')) ? $current->(@args) : $current;
$current_path .= "/$next";
}
Modified: branches/upstream/libpetal-perl/current/lib/Petal/TranslationService/MOFile.pm
URL: http://svn.debian.org/wsvn/branches/upstream/libpetal-perl/current/lib/Petal/TranslationService/MOFile.pm?rev=21752&op=diff
==============================================================================
--- branches/upstream/libpetal-perl/current/lib/Petal/TranslationService/MOFile.pm (original)
+++ branches/upstream/libpetal-perl/current/lib/Petal/TranslationService/MOFile.pm Mon Jun 16 18:57:31 2008
@@ -1,5 +1,6 @@
package Petal::TranslationService::MOFile;
use Locale::Maketext::Gettext;
+use Encode;
use strict;
use warnings;
@@ -24,6 +25,8 @@
my $self = bless { file => $file }, $class;
$self->{lexicon} = { read_mo ($file) };
+
+ ($self->{encoding}) = $self->{lexicon}{""} =~ /^Content-Type: text\/plain; charset=(.*)$/im;
return $self;
}
@@ -35,7 +38,9 @@
$self->{lexicon} || return;
my $res = $self->{lexicon}->{$id};
- return $res;
+ return undef unless defined $res;
+
+ return decode($self->{encoding}, $res);
}
Modified: branches/upstream/libpetal-perl/current/t/054_Opt_cache.t
URL: http://svn.debian.org/wsvn/branches/upstream/libpetal-perl/current/t/054_Opt_cache.t?rev=21752&op=diff
==============================================================================
--- branches/upstream/libpetal-perl/current/t/054_Opt_cache.t (original)
+++ branches/upstream/libpetal-perl/current/t/054_Opt_cache.t Mon Jun 16 18:57:31 2008
@@ -3,7 +3,7 @@
# Tests the 'disk_cache' and 'memory_cache' options to Petal->new.
#
-use Test::More tests => 8;
+use Test::More tests => 12;
use warnings;
use lib 'lib';
@@ -73,3 +73,33 @@
ok($template->memory_cache, "memory_cache option turns it on again");
+
+# Confirm cache_only defaults to off
+
+$template = new Petal (file => $file, base_dir => $data_dir);
+
+ok(!$template->cache_only, "cache_only defaults to off");
+
+
+# Confirm option can enable it
+
+$template = new Petal (file => $file, base_dir => $data_dir, cache_only => 1);
+
+ok($template->cache_only, "cache_only option turns it on");
+
+
+# Confirm global can enable it
+
+$Petal::CACHE_ONLY = 1;
+$template = new Petal (file => $file, base_dir => $data_dir);
+
+ok($template->cache_only, "\$Petal::CACHE_ONLY turns it on");
+
+
+# Confirm option can disable it
+
+$template = new Petal (file => $file, base_dir => $data_dir, cache_only => 0);
+
+ok(!$template->cache_only, "cache_only option turns it off again");
+
+
Added: branches/upstream/libpetal-perl/current/t/094_notfalse.t
URL: http://svn.debian.org/wsvn/branches/upstream/libpetal-perl/current/t/094_notfalse.t?rev=21752&op=file
==============================================================================
--- branches/upstream/libpetal-perl/current/t/094_notfalse.t (added)
+++ branches/upstream/libpetal-perl/current/t/094_notfalse.t Mon Jun 16 18:57:31 2008
@@ -1,0 +1,28 @@
+#!/usr/bin/perl
+use warnings;
+use strict;
+use lib ('lib');
+use Test::More 'no_plan';
+use Petal;
+
+$|=1;
+
+$Petal::BASE_DIR = './t/data/';
+$Petal::DISK_CACHE = 0;
+$Petal::MEMORY_CACHE = 0;
+$Petal::TAINT = 1;
+
+my $template_file = 'notfalse.xml';
+my $template = new Petal ($template_file);
+my $string = $template->process (always_false => 0, always_true => 1);
+
+like ($string, qr/A/, 'test A');
+unlike ($string, qr/B/, 'test B');
+like ($string, qr/C/, 'test C');
+unlike ($string, qr/D/, 'test D');
+unlike ($string, qr/E/, 'test E');
+like ($string, qr/F/, 'test F');
+unlike ($string, qr/G/, 'test G');
+like ($string, qr/H/, 'test H');
+
+__END__
Added: branches/upstream/libpetal-perl/current/t/096_oddeven.t
URL: http://svn.debian.org/wsvn/branches/upstream/libpetal-perl/current/t/096_oddeven.t?rev=21752&op=file
==============================================================================
--- branches/upstream/libpetal-perl/current/t/096_oddeven.t (added)
+++ branches/upstream/libpetal-perl/current/t/096_oddeven.t Mon Jun 16 18:57:31 2008
@@ -1,0 +1,30 @@
+#!/usr/bin/perl
+use warnings;
+use strict;
+use lib ('lib');
+use Test::More 'no_plan';
+use Petal;
+
+$|=1;
+
+$Petal::BASE_DIR = './t/data/';
+$Petal::DISK_CACHE = 0;
+$Petal::MEMORY_CACHE = 0;
+$Petal::TAINT = 1;
+
+my $template_file = 'oddeven.xml';
+my $template = new Petal ($template_file);
+my $string = $template->process (items => ['one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight', 'nine', 'ten']);
+
+like ($string, '/<odd>one</odd>/');
+like ($string, '/<even>two</even>/');
+like ($string, '/<odd>three</odd>/');
+like ($string, '/<even>four</even>/');
+like ($string, '/<odd>five</odd>/');
+like ($string, '/<even>six</even>/');
+like ($string, '/<odd>seven</odd>/');
+like ($string, '/<even>eight</even>/');
+like ($string, '/<odd>nine</odd>/');
+like ($string, '/<even>ten</even>/');
+
+__END__
Added: branches/upstream/libpetal-perl/current/t/097_cache_only.t
URL: http://svn.debian.org/wsvn/branches/upstream/libpetal-perl/current/t/097_cache_only.t?rev=21752&op=file
==============================================================================
--- branches/upstream/libpetal-perl/current/t/097_cache_only.t (added)
+++ branches/upstream/libpetal-perl/current/t/097_cache_only.t Mon Jun 16 18:57:31 2008
@@ -1,0 +1,38 @@
+#!/usr/bin/perl
+##############################################################################
+# Tests the 'language' option (and 'lang' alias) to Petal->new.
+# Uses t/data/language/*
+#
+
+# this is identical to t/052_Opt_language but with DISK_CACHE=1
+
+use Test::More 'no_plan';
+
+use warnings;
+use lib 'lib';
+
+use Petal;
+
+$Petal::MEMORY_CACHE = 1;
+$Petal::DISK_CACHE = 0;
+$Petal::CACHE_ONLY = 1;
+
+my $data_dir = 't/data';
+
+my $file = 'cookbook.html';
+my $template = new Petal (file => $file, base_dir => $data_dir);
+ok (eval {$template->process()}, 'process() CACHE_ONLY=1 without args should succeed');
+
+$Petal::CACHE_ONLY = 0;
+$Petal::MEMORY_CACHE = 0;
+
+$file = 'children.xml';
+my $template_A = new Petal (file => $file, base_dir => $data_dir);
+ok (!eval {$template_A->process()}, 'process() without args should fail');
+
+$Petal::MEMORY_CACHE = 1;
+
+$file = 'children.xml';
+my $template_B = new Petal (file => $file, base_dir => $data_dir, cache_only => 1);
+ok (eval {$template_B->process()}, 'process() cache_only=1 without args should succeed');
+
Added: branches/upstream/libpetal-perl/current/t/098_multiple-attributes.t
URL: http://svn.debian.org/wsvn/branches/upstream/libpetal-perl/current/t/098_multiple-attributes.t?rev=21752&op=file
==============================================================================
--- branches/upstream/libpetal-perl/current/t/098_multiple-attributes.t (added)
+++ branches/upstream/libpetal-perl/current/t/098_multiple-attributes.t Mon Jun 16 18:57:31 2008
@@ -1,0 +1,46 @@
+#!/usr/bin/perl
+
+package thing;
+
+sub new
+{
+ my $class = shift;
+ $class = ref $class || $class;
+ my $self = bless {}, $class;
+ return $self;
+}
+
+sub method
+{
+ my $self = shift;
+ join ':', @_;
+}
+
+package main;
+
+use warnings;
+use strict;
+use lib ('lib');
+use Test::More 'no_plan';
+use Petal;
+
+$|=1;
+
+$Petal::BASE_DIR = './t/data/';
+$Petal::DISK_CACHE = 0;
+$Petal::MEMORY_CACHE = 0;
+$Petal::TAINT = 1;
+
+my $template_file = 'multiple-attributes.xml';
+my $template = new Petal ($template_file);
+
+sub joinme {join ':', @_}
+my $object = new thing;
+my %hash = ( foo => 'bar' );
+
+my $string = $template->process (object => $object, coderef => \&joinme, hash => \%hash);
+
+like ($string, '/harpo:chico/');
+like ($string, '/groucho:zeppo/');
+
+__END__
Added: branches/upstream/libpetal-perl/current/t/data/multiple-attributes.xml
URL: http://svn.debian.org/wsvn/branches/upstream/libpetal-perl/current/t/data/multiple-attributes.xml?rev=21752&op=file
==============================================================================
--- branches/upstream/libpetal-perl/current/t/data/multiple-attributes.xml (added)
+++ branches/upstream/libpetal-perl/current/t/data/multiple-attributes.xml Mon Jun 16 18:57:31 2008
@@ -1,0 +1,5 @@
+<?xml version="1.0"?>
+<xml xmlns:petal="http://purl.org/petal/1.0/">
+ <foo petal:content="coderef --harpo --chico">Some stuff</foo>
+ <foo petal:content="object/method --groucho --zeppo">Some other stuff</foo>
+</xml>
Added: branches/upstream/libpetal-perl/current/t/data/notfalse.xml
URL: http://svn.debian.org/wsvn/branches/upstream/libpetal-perl/current/t/data/notfalse.xml?rev=21752&op=file
==============================================================================
--- branches/upstream/libpetal-perl/current/t/data/notfalse.xml (added)
+++ branches/upstream/libpetal-perl/current/t/data/notfalse.xml Mon Jun 16 18:57:31 2008
@@ -1,0 +1,12 @@
+<?xml version="1.0"?>
+<foo xmlns:petal="http://purl.org/petal/1.0/">
+ <bar petal:condition="false: always_false">Test A</bar>
+ <bar petal:condition="true: always_false">Test B</bar>
+ <bar petal:condition="not: always_false">Test C</bar>
+ <bar petal:condition="always_false">Test D</bar>
+
+ <bar petal:condition="false: always_true">Test E</bar>
+ <bar petal:condition="true: always_true">Test F</bar>
+ <bar petal:condition="not: always_true">Test G</bar>
+ <bar petal:condition="always_true">Test H</bar>
+</foo>
Added: branches/upstream/libpetal-perl/current/t/data/oddeven.xml
URL: http://svn.debian.org/wsvn/branches/upstream/libpetal-perl/current/t/data/oddeven.xml?rev=21752&op=file
==============================================================================
--- branches/upstream/libpetal-perl/current/t/data/oddeven.xml (added)
+++ branches/upstream/libpetal-perl/current/t/data/oddeven.xml Mon Jun 16 18:57:31 2008
@@ -1,0 +1,7 @@
+<?xml version="1.0"?>
+<foo xmlns:petal="http://purl.org/petal/1.0/">
+ <loop petal:repeat="item items" petal:omit-tag="">
+ <odd petal:content="item" petal:condition="repeat/odd">Odd item</odd>
+ <even petal:content="item" petal:condition="repeat/even">Even item</even>
+ </loop>
+</foo>
More information about the Pkg-perl-cvs-commits
mailing list