[MKDoc-commit] [Petal] Cookbook tip for odd/even rows (Jonathan Vanasco)

bruno at mkdoc.demon.co.uk bruno at mkdoc.demon.co.uk
Mon Feb 6 10:46:44 GMT 2006


Log Message:
-----------
[Petal] Cookbook tip for odd/even rows (Jonathan Vanasco)

Modified Files:
--------------
    Petal:
        Changes
    Petal/lib/Petal:
        Cookbook.pod

-------------- next part --------------
Index: Changes
===================================================================
RCS file: /var/spool/cvs/Petal/Changes,v
retrieving revision 1.146
retrieving revision 1.147
diff -LChanges -LChanges -u -r1.146 -r1.147
--- Changes
+++ Changes
@@ -1,8 +1,8 @@
 Revision history for Petal.
 
 2.19
-    - alias false: modifier as not: to match TALES spec (Jonathan)
-    - fix repeat/odd documentation bug
+    - 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)
 
 2.18 Tue Jan 17 13:01:00 2006
Index: Cookbook.pod
===================================================================
RCS file: /var/spool/cvs/Petal/lib/Petal/Cookbook.pod,v
retrieving revision 1.8
retrieving revision 1.9
diff -Llib/Petal/Cookbook.pod -Llib/Petal/Cookbook.pod -u -r1.8 -r1.9
--- lib/Petal/Cookbook.pod
+++ lib/Petal/Cookbook.pod
@@ -224,6 +224,35 @@
 
 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
 
 


More information about the MKDoc-commit mailing list