changeset 67:a0f7bfa98755

API templates now hobble along on their own two feet
author Jeff Hammel <jhammel@mozilla.com>
date Fri, 07 Jan 2011 10:58:28 -0800
parents 7821c82772f5
children cce0da329f59
files examples/doctest.txt makeitso/template.py
diffstat 2 files changed, 11 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/examples/doctest.txt	Fri Jan 07 10:53:12 2011 -0800
+++ b/examples/doctest.txt	Fri Jan 07 10:58:28 2011 -0800
@@ -85,4 +85,9 @@
     ...    name = 'foo'
     ...    templates = ['example.txt']
     ...    vars = [Variable(name='name', default='bar')]
-    >>> apitemplate = MyTemplate()
+    >>> buffer = tempfile.mktemp()
+    >>> apitemplate = MyTemplate(output=buffer)
+    >>> apitemplate.substitute()
+    >>> file(buffer).read().strip()
+    'Hello bar'
+    >>> os.remove(buffer)
--- a/makeitso/template.py	Fri Jan 07 10:53:12 2011 -0800
+++ b/makeitso/template.py	Fri Jan 07 10:58:28 2011 -0800
@@ -138,10 +138,11 @@
         self.check_missing(vars)
 
         # do the substitution
-        PolyTemplate(self.templates,
-                     output=self.output,
-                     interactive=self.interactive,
-                     variables=vars)
+        template = PolyTemplate(self._templates,
+                                output=self.output,
+                                interactive=self.interactive,
+                                variables=vars)
+        template.substitute()
                      
         self.post(**variables)