Commit 17267413 by Chris Jerdonek

Added to the View class support for disable_escape.

parent 120d4225
......@@ -88,12 +88,13 @@ class View(object):
return re.sub('[A-Z]', repl, template_name)[1:]
def render(self, encoding=None):
def render(self, encoding=None, disable_escape=False):
"""
Return the view rendered using the current context.
"""
template = Template(self.get_template(), self.load_template, output_encoding=encoding)
template = Template(self.get_template(), self.load_template, output_encoding=encoding,
disable_escape=disable_escape)
return template.render(self.context)
def get(self, key, default=None):
......
......@@ -34,6 +34,9 @@ class TestView(unittest.TestCase):
def test_escaped(self):
self.assertEquals(Escaped().render(), "<h1>Bear &gt; Shark</h1>")
def test_escaped_disabling(self):
self.assertEquals(Escaped().render(disable_escape=True), "<h1>Bear > Shark</h1>")
def test_unescaped(self):
self.assertEquals(Unescaped().render(), "<h1>Bear > Shark</h1>")
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment