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
a708d123
Commit
a708d123
authored
Jan 17, 2010
by
Eric Naeseth
Committed by
Chris Wanstrath
Feb 09, 2010
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Don't render an empty string when a tag's value is 0.
parent
abfba610
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
9 additions
and
1 deletions
+9
-1
pystache/template.py
+4
-1
tests/test_pystache.py
+5
-0
No files found.
pystache/template.py
View file @
a708d123
...
...
@@ -97,7 +97,10 @@ class Template(object):
@modifier
(
None
)
def
render_tag
(
self
,
tag_name
,
context
):
"""Given a tag name and context, finds, escapes, and renders the tag."""
return
cgi
.
escape
(
unicode
(
context
.
get
(
tag_name
,
''
)
or
''
))
raw
=
context
.
get
(
tag_name
,
''
)
if
not
raw
and
raw
is
not
0
:
return
''
return
cgi
.
escape
(
unicode
(
raw
))
@modifier
(
'!'
)
def
render_comment
(
self
,
tag_name
=
None
,
context
=
None
):
...
...
tests/test_pystache.py
View file @
a708d123
...
...
@@ -27,6 +27,11 @@ class TestPystache(unittest.TestCase):
ret
=
pystache
.
render
(
template
,
{
'name'
:
'Jon'
})
self
.
assertEquals
(
ret
,
"I think Jon wants a , right Jon?"
)
def
test_render_zero
(
self
):
template
=
'My value is {{value}}.'
ret
=
pystache
.
render
(
template
,
{
'value'
:
0
})
self
.
assertEquals
(
ret
,
'My value is 0.'
)
def
test_comments
(
self
):
template
=
"What {{! the }} what?"
ret
=
pystache
.
render
(
template
)
...
...
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