Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
P
pystache_custom
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
OpenEdx
pystache_custom
Commits
90a0ffc5
Commit
90a0ffc5
authored
Dec 18, 2011
by
Chris Jerdonek
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added a unit test re: non-ascii template characters and added to docstrings.
parent
84f08042
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
17 additions
and
0 deletions
+17
-0
pystache/template.py
+11
-0
tests/test_template.py
+6
-0
No files found.
pystache/template.py
View file @
90a0ffc5
...
...
@@ -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
)
...
...
tests/test_template.py
View file @
90a0ffc5
...
...
@@ -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'
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment