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
e38a953b
Commit
e38a953b
authored
Nov 27, 2009
by
Chris Wanstrath
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Bugfix: Methods returning False or None are not rendered
parent
09ab3f95
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
12 additions
and
3 deletions
+12
-3
HISTORY.md
+1
-0
examples/simple.mustache
+2
-2
examples/simple.py
+3
-0
pystache/template.py
+1
-1
tests/test_pystache.py
+5
-0
No files found.
HISTORY.md
View file @
e38a953b
## 0.2.0 (2009-??-??)
*
Bugfix: Methods returning False or None are not rendered
*
Add support for using non-callables as View attributes.
[
joshthecoder
]
*
Allow using View instances as attributes.
[
joshthecoder
]
...
...
examples/simple.mustache
View file @
e38a953b
Hi
{{
thing
}}
!
\ No newline at end of file
Hi
{{
thing
}}
!
{{
blank
}}
\ No newline at end of file
examples/simple.py
View file @
e38a953b
...
...
@@ -5,3 +5,6 @@ class Simple(pystache.View):
def
thing
(
self
):
return
"pizza"
def
blank
(
self
):
pass
pystache/template.py
View file @
e38a953b
...
...
@@ -94,7 +94,7 @@ 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
(
str
(
context
.
get
(
tag_name
,
''
)))
return
cgi
.
escape
(
str
(
context
.
get
(
tag_name
,
''
)
or
''
))
@modifier
(
'!'
)
def
render_comment
(
self
,
tag_name
=
None
,
context
=
None
):
...
...
tests/test_pystache.py
View file @
e38a953b
...
...
@@ -20,6 +20,11 @@ class TestPystache(unittest.TestCase):
ret
=
pystache
.
render
(
template
,
{
'name'
:
'Jon'
,
'thing'
:
'racecar'
})
self
.
assertEquals
(
ret
,
"I think Jon wants a racecar, right Jon?"
)
def
test_ignores_misses
(
self
):
template
=
"I think {{name}} wants a {{thing}}, right {{name}}?"
ret
=
pystache
.
render
(
template
,
{
'name'
:
'Jon'
})
self
.
assertEquals
(
ret
,
"I think Jon wants a , right Jon?"
)
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