[Checkins] SVN: z3c.pt/trunk/ METAL macros should render in the template where they're defined.

Malthe Borch mborch at gmail.com
Mon Sep 1 13:19:45 EDT 2008


Log message for revision 90658:
  METAL macros should render in the template where they're defined.

Changed:
  U   z3c.pt/trunk/CHANGES.txt
  U   z3c.pt/trunk/src/z3c/pt/translation.py
  U   z3c.pt/trunk/src/z3c/pt/zpt.txt

-=-
Modified: z3c.pt/trunk/CHANGES.txt
===================================================================
--- z3c.pt/trunk/CHANGES.txt	2008-09-01 16:37:56 UTC (rev 90657)
+++ z3c.pt/trunk/CHANGES.txt	2008-09-01 17:19:44 UTC (rev 90658)
@@ -6,6 +6,8 @@
 
   Backwards incompatibilities
 
+- Template output is now always converted to unicode. [malthe]
+  
 - The ``ViewPageTemplateFile`` class now uses 'path' as the default
   expression type. [malthe]
   
@@ -132,6 +134,9 @@
   output unchanged. [chrism]
 
   Bugfixes
+
+- METAL macros should render in the template where they're
+  defined. [malthe]
   
 - Avoid printing a line-break when we repeat over a single item
   only. [malthe]

Modified: z3c.pt/trunk/src/z3c/pt/translation.py
===================================================================
--- z3c.pt/trunk/src/z3c/pt/translation.py	2008-09-01 16:37:56 UTC (rev 90657)
+++ z3c.pt/trunk/src/z3c/pt/translation.py	2008-09-01 17:19:44 UTC (rev 90658)
@@ -47,12 +47,9 @@
             for element in self.element:
                 element.node.visit()
                     
-    def visit(self, skip_macro=True):
+    def visit(self):
         assert self.stream is not None, "Must use ``start`` method."
 
-        if skip_macro and (self.define_macro):
-            return
-
         for element in self.element:
             if not isinstance(element, Element):
                 self.wrap_literal(element)

Modified: z3c.pt/trunk/src/z3c/pt/zpt.txt
===================================================================
--- z3c.pt/trunk/src/z3c/pt/zpt.txt	2008-09-01 16:37:56 UTC (rev 90657)
+++ z3c.pt/trunk/src/z3c/pt/zpt.txt	2008-09-01 17:19:44 UTC (rev 90658)
@@ -264,7 +264,7 @@
   ...      xmlns:tal="http://xml.zope.org/namespaces/tal"
   ...      xmlns:metal="http://xml.zope.org/namespaces/metal">
   ...   <div class="greeting" metal:define-macro="greeting">
-  ...     Hello, ${name}!
+  ...     Hello, ${name|string:earth}!
   ...   </div>
   ...   <div tal:define="name 'world'">
   ...     <div metal:use-macro="template.macros['greeting']" />
@@ -277,10 +277,14 @@
   >>> template = MockTemplate(body, ZopePageTemplateParser())
   >>> print render_zpt(body, template=template)
   <div>
+    <div class="greeting">
+      Hello, earth!
+    </div>
     <div>
       <div class="greeting">
-        Hello, world!
-      </div>
+      Hello, world!
+    </div>
+  <BLANKLINE>
     </div>  
   </div>
 
@@ -314,6 +318,9 @@
   >>> template = MockTemplate(body, ZopePageTemplateParser())
   >>> print render_zpt(body, template=template)
   <div>
+    <div>
+      Hello, <b class="name">stranger!</b>
+    </div>
   <BLANKLINE>
       <div>
       Hello, <b class="name">earth!</b>



More information about the Checkins mailing list