From 41478670981ed37f7b2c46bba55d1d84841adb9b Mon Sep 17 00:00:00 2001 From: mdipierro Date: Fri, 24 May 2013 08:28:45 -0500 Subject: [PATCH] better handling of delimeters in template, thanks Corne Dickens --- VERSION | 2 +- gluon/template.py | 9 +++++---- gluon/tools.py | 2 ++ 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/VERSION b/VERSION index d7ccfdf2..fb57f9ee 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -Version 2.4.6-stable+timestamp.2013.05.19.22.13.58 +Version 2.4.6-stable+timestamp.2013.05.24.08.27.55 diff --git a/gluon/template.py b/gluon/template.py index 50312f97..4425a202 100644 --- a/gluon/template.py +++ b/gluon/template.py @@ -562,8 +562,8 @@ class TemplateParser(object): if in_tag: line = i - # Get rid of '{{' and '}}' - line = line[2:-2].strip() + # Get rid of delimiters + line = line[len(self.delimiters[0]):-len(self.delimiters[1])].strip() # This is bad juju, but let's do it anyway if not line: @@ -832,7 +832,8 @@ def render(content="hello world", path=None, context={}, lexers={}, - delimiters=('{{', '}}') + delimiters=('{{', '}}'), + writer='response.write' ): """ >>> render() @@ -895,7 +896,7 @@ def render(content="hello world", # Execute the template. code = str(TemplateParser(stream.read( - ), context=context, path=path, lexers=lexers, delimiters=delimiters)) + ), context=context, path=path, lexers=lexers, delimiters=delimiters, writer=writer)) try: exec(code) in context except Exception: diff --git a/gluon/tools.py b/gluon/tools.py index cdfdeddf..8995e048 100644 --- a/gluon/tools.py +++ b/gluon/tools.py @@ -5269,6 +5269,7 @@ class Wiki(object): else: return dict(title=page.title, slug=page.slug, + page=page, content=XML(self.fix_hostname(page.html)), tags=page.tags, created_on=page.created_on, @@ -5281,6 +5282,7 @@ class Wiki(object): else: return dict(title=page.title, slug=page.slug, + page=page, content=page.body, tags=page.tags, created_on=page.created_on,