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
f03c85c7
Commit
f03c85c7
authored
Nov 16, 2009
by
Joshua Roesslein
Committed by
Chris Wanstrath
Nov 16, 2009
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add support for using non-callables as View attributes.
parent
613a8cd2
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
13 additions
and
1 deletions
+13
-1
HISTORY.md
+4
-0
pystache/view.py
+4
-1
tests/test_view.py
+5
-0
No files found.
HISTORY.md
View file @
f03c85c7
## 0.2.0 (2009-11-16)
*
Add support for using non-callables as View attributes.
[
joshthecoder
]
## 0.1.1 (2009-11-13)
## 0.1.1 (2009-11-13)
*
Ensure we're dealing with strings, always
*
Ensure we're dealing with strings, always
...
...
pystache/view.py
View file @
f03c85c7
...
@@ -79,7 +79,10 @@ class View(object):
...
@@ -79,7 +79,10 @@ class View(object):
if
attr
in
self
.
context
:
if
attr
in
self
.
context
:
return
self
.
context
[
attr
]
return
self
.
context
[
attr
]
elif
hasattr
(
self
,
attr
):
elif
hasattr
(
self
,
attr
):
return
getattr
(
self
,
attr
)()
try
:
return
getattr
(
self
,
attr
)()
except
TypeError
:
return
getattr
(
self
,
attr
)
else
:
else
:
return
default
return
default
...
...
tests/test_view.py
View file @
f03c85c7
...
@@ -21,6 +21,11 @@ class TestView(unittest.TestCase):
...
@@ -21,6 +21,11 @@ class TestView(unittest.TestCase):
view
=
Simple
()
view
=
Simple
()
self
.
assertEquals
(
view
.
render
(),
"Hi pizza!"
)
self
.
assertEquals
(
view
.
render
(),
"Hi pizza!"
)
def
test_non_callable_attributes
(
self
):
view
=
Simple
()
view
.
thing
=
'Chris'
self
.
assertEquals
(
view
.
render
(),
"Hi Chris!"
)
def
test_complex
(
self
):
def
test_complex
(
self
):
self
.
assertEquals
(
ComplexView
()
.
render
(),
"""<h1>Colors</h1>
self
.
assertEquals
(
ComplexView
()
.
render
(),
"""<h1>Colors</h1>
<ul>
<ul>
...
...
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