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
02d87ba6
Commit
02d87ba6
authored
Jan 01, 2012
by
Chris Jerdonek
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixed last spec-test: non-string template during rendering process.
parent
8025298f
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
13 additions
and
3 deletions
+13
-3
pystache/renderengine.py
+12
-2
tests/test_renderengine.py
+1
-1
No files found.
pystache/renderengine.py
View file @
02d87ba6
...
...
@@ -116,6 +116,11 @@ class RenderEngine(object):
context: a Context instance.
"""
# Be strict but not too strict. In other words, accept str instead
# of unicode, but don't assume anything about the encoding (e.g.
# don't use self.literal).
template
=
unicode
(
template
)
_template
=
Template
(
template
=
template
)
_template
.
to_unicode
=
self
.
literal
...
...
@@ -424,6 +429,11 @@ class Template(object):
# rendered against the default delimiters, then
# interpolated in place of the lambda.
template
=
val
()
if
not
isinstance
(
template
,
basestring
):
# In case the template is an integer, for example.
template
=
str
(
template
)
if
type
(
template
)
is
not
unicode
:
template
=
self
.
to_unicode
(
template
)
val
=
self
.
render_template
(
template
,
context
)
if
not
isinstance
(
val
,
basestring
):
...
...
@@ -600,8 +610,8 @@ class Template(object):
context: a Context instance
"""
if
not
isinstance
(
template
,
basestring
)
:
raise
AssertionError
(
"template:
%
s"
%
repr
(
template
))
if
type
(
template
)
is
not
unicode
:
raise
Exception
(
"Argument 'template' not unicode:
%
s:
%
s"
%
(
type
(
template
),
repr
(
template
)
))
parse_tree
=
self
.
parse_string_to_tree
(
template
=
template
,
delims
=
delims
)
return
render_parse_tree
(
parse_tree
,
context
,
template
)
...
...
tests/test_renderengine.py
View file @
02d87ba6
...
...
@@ -68,7 +68,7 @@ class RenderEngineEnderTestCase(unittest.TestCase):
"""
engine
=
self
.
_engine
()
partials
=
{
'partial'
:
"{{person}}"
}
partials
=
{
'partial'
:
u
"{{person}}"
}
engine
.
load_partial
=
lambda
key
:
partials
[
key
]
self
.
_assert_render
(
'Hi Mom'
,
'Hi {{>partial}}'
,
{
'person'
:
'Mom'
},
engine
=
engine
)
...
...
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