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
8954e01f
Commit
8954e01f
authored
Jan 12, 2011
by
Carl Whittaker
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixing views as attributes not being rendered before display
parent
c859dfa2
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
7 additions
and
9 deletions
+7
-9
pystache/template.py
+4
-8
pystache/view.py
+2
-0
tests/test_simple.py
+1
-1
No files found.
pystache/template.py
View file @
8954e01f
...
@@ -99,19 +99,15 @@ class Template(object):
...
@@ -99,19 +99,15 @@ class Template(object):
from
view
import
View
from
view
import
View
view
=
View
(
context
=
context
)
view
=
View
(
context
=
context
)
view
.
template_path
=
self
.
view
.
template_path
view
.
template_encoding
=
self
.
view
.
template_encoding
view
.
parent
=
self
.
view
view
.
parent
=
self
.
view
return
Template
(
template
,
view
)
.
render
()
return
Template
(
template
,
view
)
.
render
()
def
_render_list
(
self
,
template
,
listing
):
def
_render_list
(
self
,
template
,
listing
):
from
view
import
View
insides
=
[]
insides
=
[]
for
item
in
listing
:
for
item
in
listing
:
view
=
View
(
context
=
item
)
insides
.
append
(
self
.
_render_dictionary
(
template
,
item
))
view
.
template_path
=
self
.
view
.
template_path
view
.
template_encoding
=
self
.
view
.
template_encoding
view
.
parent
=
self
.
view
insides
.
append
(
Template
(
template
,
view
)
.
render
())
return
''
.
join
(
insides
)
return
''
.
join
(
insides
)
...
...
pystache/view.py
View file @
8954e01f
...
@@ -20,6 +20,8 @@ class View(object):
...
@@ -20,6 +20,8 @@ class View(object):
attr
=
self
.
context
.
get
(
attr
,
getattr
(
self
,
attr
,
self
.
_get_from_parent
(
attr
,
default
)))
attr
=
self
.
context
.
get
(
attr
,
getattr
(
self
,
attr
,
self
.
_get_from_parent
(
attr
,
default
)))
if
hasattr
(
attr
,
'__call__'
)
and
type
(
attr
)
is
UnboundMethodType
:
if
hasattr
(
attr
,
'__call__'
)
and
type
(
attr
)
is
UnboundMethodType
:
return
attr
()
return
attr
()
if
hasattr
(
attr
,
'render'
):
return
attr
.
render
(
encoding
=
self
.
template_encoding
)
else
:
else
:
return
attr
return
attr
...
...
tests/test_simple.py
View file @
8954e01f
...
@@ -31,7 +31,7 @@ class TestSimple(unittest.TestCase):
...
@@ -31,7 +31,7 @@ class TestSimple(unittest.TestCase):
view
=
TemplatePartial
()
view
=
TemplatePartial
()
self
.
assertEquals
(
pystache
.
Template
(
'{{>inner_partial}}'
,
view
)
.
render
(),
'Again, Welcome!'
)
self
.
assertEquals
(
pystache
.
Template
(
'{{>inner_partial}}'
,
view
)
.
render
(),
'Again, Welcome!'
)
self
.
assertEquals
(
pystache
.
Template
(
'{{#looping}}{{>inner_partial}} {{/looping}}'
,
view
)
.
render
(),
'''Again, Welcome! Again, Welcome! Again, Welcome!'''
)
self
.
assertEquals
(
pystache
.
Template
(
'{{#looping}}{{>inner_partial}} {{/looping}}'
,
view
)
.
render
(),
'''Again, Welcome! Again, Welcome! Again, Welcome!
'''
)
def
test_non_existent_value_renders_blank
(
self
):
def
test_non_existent_value_renders_blank
(
self
):
view
=
Simple
()
view
=
Simple
()
...
...
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