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
c7e71d8f
Commit
c7e71d8f
authored
May 04, 2012
by
Chris Jerdonek
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixed issue #118: "Handle lambda section values returning non-ascii, non-unicode"
See--
https://github.com/defunkt/pystache/issues/118
parent
ef3ef4bf
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
20 additions
and
0 deletions
+20
-0
HISTORY.rst
+1
-0
pystache/renderengine.py
+2
-0
pystache/tests/test_renderengine.py
+17
-0
No files found.
HISTORY.rst
View file @
c7e71d8f
...
...
@@ -8,6 +8,7 @@ History
``Renderer(missing_tags='strict')`` (issue #110).
* Bugfix: exceptions raised from a property are no longer swallowed when
getting a key from a context stack (issue #110).
* Bugfix: lambda section values can now return non-ascii, non-unicode strings (issue #118).
0.5.2 (2012-05-03)
------------------
...
...
pystache/renderengine.py
View file @
c7e71d8f
...
...
@@ -220,6 +220,8 @@ class RenderEngine(object):
#
# TODO: should we check the arity?
new_template
=
element
(
template
[
section_start_index
:
section_end_index
])
# Make sure we are dealing with a unicode template string.
new_template
=
self
.
literal
(
new_template
)
new_parsed_template
=
self
.
_parse
(
new_template
,
delimiters
=
delims
)
parts
.
append
(
new_parsed_template
.
render
(
context
))
continue
...
...
pystache/tests/test_renderengine.py
View file @
c7e71d8f
...
...
@@ -473,6 +473,23 @@ class RenderTests(unittest.TestCase, AssertStringMixin, AssertExceptionMixin):
context
=
{
'test'
:
(
lambda
text
:
'Hi
%
s'
%
text
)}
self
.
_assert_render
(
u'Hi Mom'
,
template
,
context
)
def
test_section__lambda__returning_nonascii_nonunicode
(
self
):
"""
Test a lambda section value returning a non-ascii, non-unicode string.
"""
def
literal
(
s
):
if
isinstance
(
s
,
unicode
):
return
s
return
unicode
(
s
,
encoding
=
'utf8'
)
engine
=
self
.
_engine
()
engine
.
literal
=
literal
template
=
'{{#lambda}}{{/lambda}}'
context
=
{
'lambda'
:
lambda
text
:
u'abcdé'
.
encode
(
'utf-8'
)}
self
.
_assert_render
(
u'abcdé'
,
template
,
context
,
engine
=
engine
)
def
test_section__iterable
(
self
):
"""
Check that objects supporting iteration (aside from dicts) behave like lists.
...
...
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