Commit 90a0ffc5 by Chris Jerdonek

Added a unit test re: non-ascii template characters and added to docstrings.

parent 84f08042
......@@ -68,6 +68,9 @@ class Template(object):
Arguments:
template: a template string as a unicode string. Behavior is
undefined if the string has type str.
context: a dictionary, Context, or View instance.
load_template: the function for loading partials. The function should
......@@ -238,6 +241,14 @@ class Template(object):
"""
Return the template rendered using the current context.
The return value is a unicode string, unless the encoding argument
is not None, in which case the return value has type str (encoded
using that encoding).
Arguments:
encoding: the name of the encoding as a string, for example "utf-8".
"""
template = self._render_sections(self.template)
result = self._render_tags(template)
......
......@@ -44,6 +44,12 @@ class TemplateTestCase(unittest.TestCase):
self.assertTrue(isinstance(actual, str))
self.assertEquals(actual, 'foo')
def test_render__non_ascii_character(self):
template = Template(u'Poincaré')
actual = template.render()
self.assertTrue(isinstance(actual, unicode))
self.assertEquals(actual, u'Poincaré')
def test_render__context(self):
template = Template('Hi {{person}}', {'person': 'Mom'})
self.assertEquals(template.render(), 'Hi Mom')
......
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