[Checkins] SVN: z3c.viewtemplate/trunk/ bugfix: options did not get passed in to macro templates

Bernd Roessl bernd.roessl at lovelysystems.com
Wed Oct 31 10:32:43 EDT 2007


Log message for revision 81271:
  bugfix: options did not get passed in to macro templates

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

-=-
Modified: z3c.viewtemplate/trunk/CHANGES.txt
===================================================================
--- z3c.viewtemplate/trunk/CHANGES.txt	2007-10-31 14:02:39 UTC (rev 81270)
+++ z3c.viewtemplate/trunk/CHANGES.txt	2007-10-31 14:32:43 UTC (rev 81271)
@@ -2,6 +2,13 @@
 Changes for z3c.viewtemplate
 ============================
 
+
+Version 0.3.1 (2007-10-31)
+========================
+
+- bugfix: options did not get passed in to macro templates
+
+
 Version 0.3.0 (2007-09-27)
 ========================
 
@@ -10,12 +17,8 @@
 
 - no dev release anymore
 
+
 Version 0.2 (2007-05-01)
 ========================
 
 - Fire a BeforeUpdateEvent in the base views. This requires zope 3.4
-
-
-
-
-

Modified: z3c.viewtemplate/trunk/setup.py
===================================================================
--- z3c.viewtemplate/trunk/setup.py	2007-10-31 14:02:39 UTC (rev 81270)
+++ z3c.viewtemplate/trunk/setup.py	2007-10-31 14:32:43 UTC (rev 81271)
@@ -2,7 +2,7 @@
 from setuptools import setup, find_packages
 
 setup(name='z3c.viewtemplate',
-      version='0.3.0',
+      version='0.3.1',
       author = "Zope Community",
       author_email = "zope3-dev at zope.org",
       description = open("README.txt").read(),

Modified: z3c.viewtemplate/trunk/src/z3c/viewtemplate/README.txt
===================================================================
--- z3c.viewtemplate/trunk/src/z3c/viewtemplate/README.txt	2007-10-31 14:02:39 UTC (rev 81270)
+++ z3c.viewtemplate/trunk/src/z3c/viewtemplate/README.txt	2007-10-31 14:32:43 UTC (rev 81271)
@@ -112,6 +112,7 @@
   >>> print templatedView()
   <div>view</div>
 
+
 Use of macros.
 
   >>> macroTemplate = os.path.join(temp_dir, 'macroTemplate.pt')
@@ -120,7 +121,7 @@
   ...     <div>macro1</div>
   ...   </metal:block>
   ...   <metal:block define-macro="macro2">
-  ...     <div>macro2</div>
+  ...   <div tal:content="options/foo">macro2</div>
   ...   </metal:block>
   ...   ''')
 
@@ -128,7 +129,14 @@
   >>> print factory(view, request)()
   <div>macro1</div>
 
+Since it is possible to pass options to the viewlet let's prove if this
+is possible for macros as well::
 
+  >>> factory = TemplateFactory(macroTemplate, 'macro2', 'text/html')
+  >>> print factory(view, request)(foo='bar')
+  <div>bar</div>
+
+
 Why didn't we use named templates from the ``zope.formlib`` package?
 
 While named templates allow us to separate the view code from the template
@@ -175,6 +183,6 @@
   >>> component.provideAdapter(factory,
   ...            (IMyUseOfView, IDefaultBrowserLayer),
   ...            IPageTemplate)
-  >>> print simple.template()
-  <div>macro2</div>
+  >>> print simple.template(foo='bar')
+  <div>bar</div>
 

Modified: z3c.viewtemplate/trunk/src/z3c/viewtemplate/macro.py
===================================================================
--- z3c.viewtemplate/trunk/src/z3c/viewtemplate/macro.py	2007-10-31 14:02:39 UTC (rev 81270)
+++ z3c.viewtemplate/trunk/src/z3c/viewtemplate/macro.py	2007-10-31 14:32:43 UTC (rev 81271)
@@ -37,7 +37,9 @@
             raise KeyError('Macro "%s" not found in file "%s"'% (
                 self.macroName, self.template.filename))
         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