From bd24077a50d7dca22159da474502ffd4c307ea6f Mon Sep 17 00:00:00 2001 From: Pieter van de Bruggen Date: Sun, 20 Feb 2011 20:54:36 -0800 Subject: [PATCH] Cleaning up the fetch routine a bit. Also deleting a bit of unintended diagnostic code. --- pystache/template.py | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/pystache/template.py b/pystache/template.py index 8c6b42a..85d0e89 100644 --- a/pystache/template.py +++ b/pystache/template.py @@ -75,20 +75,19 @@ class Template(object): captures['whitespace'] = '' # TODO: Process the remaining tag types. - print captures['name'] - fetch = lambda view: unicode(view.get(captures['name'])) + fetch = lambda view: view.get(captures['name']) + if captures['tag'] == '!': pass elif captures['tag'] == '=': - print '"', captures['name'], '"' self.otag, self.ctag = captures['name'].split() self._compile_regexps() elif captures['tag'] in ['{', '&']: - buffer.append(fetch) + buffer.append(lambda view: unicode(fetch(view))) elif captures['tag'] == '': - buffer.append(lambda view: cgi.escape(fetch(view), True)) + buffer.append(lambda view: cgi.escape(unicode(fetch(view)), True)) else: - print 'Error!' + raise return pos