[Checkins] SVN: z3c.template/trunk/ forward the template kwargs to the options of the macro

Juergen Kartnaller juergen at kartnaller.at
Wed Oct 31 10:02:40 EDT 2007


Log message for revision 81270:
  forward the template kwargs to the options of the macro
  

Changed:
  U   z3c.template/trunk/CHANGES.txt
  U   z3c.template/trunk/src/z3c/template/README.txt
  U   z3c.template/trunk/src/z3c/template/macro.py

-=-
Modified: z3c.template/trunk/CHANGES.txt
===================================================================
--- z3c.template/trunk/CHANGES.txt	2007-10-31 13:27:42 UTC (rev 81269)
+++ z3c.template/trunk/CHANGES.txt	2007-10-31 14:02:39 UTC (rev 81270)
@@ -2,6 +2,11 @@
 CHANGES
 =======
 
+after 1.1.0
+-----------
+
+* forward the template kwargs to the options of the macro
+
 1.1.0 (2007-10-08)
 ------------------
 

Modified: z3c.template/trunk/src/z3c/template/README.txt
===================================================================
--- z3c.template/trunk/src/z3c/template/README.txt	2007-10-31 13:27:42 UTC (rev 81269)
+++ z3c.template/trunk/src/z3c/template/README.txt	2007-10-31 14:02:39 UTC (rev 81270)
@@ -345,12 +345,17 @@
   ...   </metal:block>
   ...   <metal:block define-macro="macro2">
   ...     <div>macro2</div>
+  ...     <div tal:content="options/div2">the content of div 2</div>
   ...   </metal:block>
   ...   ''')
 
   >>> factory = TemplateFactory(macroTemplate, 'text/html', 'macro1')
   >>> print factory(view, request)()
   <div>macro1</div>
+  >>> m2factory = TemplateFactory(macroTemplate, 'text/html', 'macro2')
+  >>> print m2factory(view, request)(div2="from the options")
+  <div>macro2</div>
+  <div>from the options</div>
 
 
 Why didn't we use named templates from the ``zope.formlib`` package?

Modified: z3c.template/trunk/src/z3c/template/macro.py
===================================================================
--- z3c.template/trunk/src/z3c/template/macro.py	2007-10-31 13:27:42 UTC (rev 81269)
+++ z3c.template/trunk/src/z3c/template/macro.py	2007-10-31 14:02:39 UTC (rev 81270)
@@ -34,7 +34,8 @@
     def __call__(self, *args, **kwargs):
         program = self.template.macros[self.macroName]
         output = StringIO(u'')
-        namespace = self.template.pt_getContext(self.view, self.request)
+        namespace = self.template.pt_getContext(
+                        self.view, self.request, options=kwargs)
         context = self.template.pt_getEngineContext(namespace)
         TALInterpreter(program, None,
                        context, output, tal=True, showtal=False,



More information about the Checkins mailing list