[MKDoc-commit] [Petal] fix repeat/odd documentation bug; tests for odd even methods

bruno at mkdoc.demon.co.uk bruno at mkdoc.demon.co.uk
Thu Feb 2 23:16:17 GMT 2006


Log Message:
-----------
[Petal] fix repeat/odd documentation bug; tests for odd even methods

Modified Files:
--------------
    Petal:
        Changes
    Petal/lib:
        Petal.pm

Added Files:
-----------
    Petal/t:
        096_oddeven.t
    Petal/t/data:
        oddeven.xml

-------------- next part --------------
Index: Changes
===================================================================
RCS file: /var/spool/cvs/Petal/Changes,v
retrieving revision 1.144
retrieving revision 1.145
diff -LChanges -LChanges -u -r1.144 -r1.145
--- Changes
+++ Changes
@@ -2,6 +2,7 @@
 
 2.19
     - alias false: modifier as not: to match TALES spec (Jonathan)
+    - fix repeat/odd documentation bug
 
 2.18 Tue Jan 17 13:01:00 2006
     - $Petal::CodeGenerator::PI_RE should be applied newline insensitively
Index: Petal.pm
===================================================================
RCS file: /var/spool/cvs/Petal/lib/Petal.pm,v
retrieving revision 1.139
retrieving revision 1.140
diff -Llib/Petal.pm -Llib/Petal.pm -u -r1.139 -r1.140
--- lib/Petal.pm
+++ lib/Petal.pm
@@ -1079,7 +1079,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 +1087,7 @@
       </tr>
       <tr 
         class="even"
-        tal:condition="true: audience/even"
+        tal:condition="repeat/even"
       >
         <td> 
           This a even row.
--- /dev/null
+++ t/096_oddeven.t
@@ -0,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__
--- /dev/null
+++ t/data/oddeven.xml
@@ -0,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 MKDoc-commit mailing list