Author: jmorliaguet
Date: Sat Feb 11 22:21:58 2006
New Revision: 2363

Modified:
   cpsskins/branches/jmo-perspectives/ui/framework/ctal.js
Log:

- only recurse if needed (removes the "item/id" bug)



Modified: cpsskins/branches/jmo-perspectives/ui/framework/ctal.js
==============================================================================
--- cpsskins/branches/jmo-perspectives/ui/framework/ctal.js     (original)
+++ cpsskins/branches/jmo-perspectives/ui/framework/ctal.js     Sat Feb 11 
22:21:58 2006
@@ -142,8 +142,9 @@
 
 ctal.tal_repeat = function(tmpl, value, data) {
   var nmx = ctal.get_nameexpr(value);
+  var datas;
   try {
-    var datas = ctal.eval_expr(data, nmx[1]);
+    datas = ctal.eval_expr(data, nmx[1]);
   } catch (e) {
     if (e.name == ctal.TALESError.name) {
       throw new ctal.TALError(nmx[1]+" is not an Array.")
@@ -167,6 +168,7 @@
 /* general processor */
 
 ctal.process_ctal = function(tmpl, data) {
+  var recurse = true;
   if (tmpl.nodeType == 1) {
     var parsers = ctal.parsers;
     for (ctal_attr in parsers) {
@@ -182,14 +184,19 @@
         tmpl.removeAttribute(ctal_attr);
 
         var parser = parsers[ctal_attr];
-        parser(tmpl, attrnode.value, data)
+        if (!parser.recurse) {
+          recurse = false;
+        }
+        parser.parse(tmpl, attrnode.value, data)
         break;
       }
     }
   }
   //  recursion
-  for (var i=0; i<tmpl.childNodes.length; i++) {
-    ctal.process_ctal(tmpl.childNodes[i], data);
+  if (recurse) {
+    for (var i=0; i<tmpl.childNodes.length; i++) {
+      ctal.process_ctal(tmpl.childNodes[i], data);
+    }
   }
 }
 
@@ -224,7 +231,7 @@
   for (var i=0; i < pathelems.length; i++) {
     traverse = traverse[pathelems[i]];
     if (typeof traverse == "undefined") {
-      throw new ctal.TALESError('No data found for "' + path + '"')
+       throw new ctal.TALESError('No data found for "' + path + '"')
     }
   }
   return traverse;
@@ -243,12 +250,13 @@
   return cond && (cond != "")
 }
 
+// the parsing order matters
 ctal.parsers = {
-  "condition": ctal.tal_condition,
-  "repeat": ctal.tal_repeat,
-  "content": ctal.tal_content,
-  "attributes": ctal.tal_attributes,
-  "omit-tag": ctal.tal_omit_tag,
-  "replace": ctal.tal_replace
+  "condition": {'parse': ctal.tal_condition, 'recurse': true},
+  "repeat": {'parse': ctal.tal_repeat, 'recurse': false},
+  "content": {'parse': ctal.tal_content, 'recurse': false},
+  "replace": {'parse': ctal.tal_replace, 'recurse': false},
+  "omit-tag": {'parse': ctal.tal_omit_tag, 'recurse': true},
+  "attributes": {'parse': ctal.tal_attributes, 'recurse': true}
   };
 
-- 
http://lists.nuxeo.com/mailman/listinfo/z3lab-checkins

Reply via email to