cocoon-docs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From d...@cocoon.apache.org
Subject [Cocoon Wiki] Updated: WoodyScratchpad
Date Mon, 01 Nov 2004 20:40:39 GMT
   Date: 2004-11-01T12:40:39
   Editor: TimLarson <tim@keow.org>
   Wiki: Cocoon Wiki
   Page: WoodyScratchpad
   URL: http://wiki.apache.org/cocoon/WoodyScratchpad

   no comment

Change Log:

------------------------------------------------------------------------------
@@ -29,7 +29,7 @@
   <fd:macro expand="mymacro"/>
 </fd:struct>
 }}}
-Is equivalent to:
+is equivalent to this:
 {{{
 <fd:struct id="mystruct">
   <fd:field id="myfield">
@@ -40,11 +40,71 @@
   </fd:field>
 </fd:struct>
 }}}
-Except that now you have a reusable macro named "mymacro"
+...except that now you have a reusable macro named "mymacro"
 that you could expand in several places in your form instead
 of typing the same list of widget definition over and over
 in each place where you need them.
 
+----
+
+Sometimes you may want to define a general macro, and then
+create variants based on it.  Think of this as creating a
+blueprint that contains most of your details, and then making
+photocopies of this blueprint to fill in different finishing
+touches to customize each copy.  In terms of forms, this
+would consist of adding, deleting, and/or modifying the widget
+definitions in the copies of the main macro.
+
+So this:
+{{{
+<fd:macro define="mymacro">
+  <fd:field id="myfield">
+    ...
+  </fd:field>
+  <fd:field id="yourfield">
+    ...
+  </fd:field>
+</fd:macro>
+
+<fd:macro extend="mymacro" define="yourmacro">
+  <fd:add>
+    <fd:field id="anotherfield">
+      ...
+    </fd:field>
+  </fd:add>
+</fd:macro>
+
+<fd:struct id="mystruct">
+  <fd:macro expand="mymacro"/>
+</fd:struct>
+
+<fd:struct id="yourstruct">
+  <fd:macro expand="yourmacro"/>
+</fd:struct>
+}}}
+would be equivalent to:
+{{{
+<fd:struct id="mystruct">
+  <fd:field id="myfield">
+    ...
+  </fd:field>
+  <fd:field id="yourfield">
+    ...
+  </fd:field>
+</fd:struct>
+
+<fd:struct id="yourstruct">
+  <fd:field id="myfield">
+    ...
+  </fd:field>
+  <fd:field id="yourfield">
+    ...
+  </fd:field>
+  <fd:field id="anotherfield">
+    ...
+  </fd:field>
+</fd:struct>
+}}}
 ----
 
 Create a widget:[[BR]]

Mime
View raw message