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
9d2da6ae
Commit
9d2da6ae
authored
Dec 27, 2011
by
Chris Jerdonek
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Renamed the loader argument of View.__init__() to "partials".
parent
aaed5225
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
11 additions
and
12 deletions
+11
-12
pystache/view.py
+10
-11
tests/test_view.py
+1
-1
No files found.
pystache/view.py
View file @
9d2da6ae
...
@@ -25,23 +25,20 @@ class View(object):
...
@@ -25,23 +25,20 @@ class View(object):
_loader
=
None
_loader
=
None
_renderer
=
None
_renderer
=
None
def
__init__
(
self
,
template
=
None
,
context
=
None
,
loader
=
None
,
**
kwargs
):
def
__init__
(
self
,
template
=
None
,
context
=
None
,
partials
=
None
,
**
kwargs
):
"""
"""
Construct a View instance.
Construct a View instance.
Arguments:
Arguments:
loader: the object (e.g. pystache.Loader or dictionary) responsible
partials: the object (e.g. pystache.Loader or dictionary)
for loading templates during the rendering process, for example
responsible for loading partials during the rendering process.
when loading partials. The object should have a get() metho
d
The object should have a get() method that accepts a string an
d
that accepts a string and returns the corresponding template
returns the corresponding template as a string, preferably as a
as a string, preferably as a unicode string. The method should
unicode string. The method should return None if there is no
return None if there is no template with that name
.
template with that name, or raise an exception
.
"""
"""
if
loader
is
not
None
:
self
.
_loader
=
loader
if
template
is
not
None
:
if
template
is
not
None
:
self
.
template
=
template
self
.
template
=
template
...
@@ -51,6 +48,8 @@ class View(object):
...
@@ -51,6 +48,8 @@ class View(object):
if
kwargs
:
if
kwargs
:
_context
.
push
(
kwargs
)
_context
.
push
(
kwargs
)
self
.
_partials
=
partials
self
.
context
=
_context
self
.
context
=
_context
def
_get_renderer
(
self
):
def
_get_renderer
(
self
):
...
@@ -60,7 +59,7 @@ class View(object):
...
@@ -60,7 +59,7 @@ class View(object):
# instantiation some of the attributes on which the Renderer
# instantiation some of the attributes on which the Renderer
# depends. This lets users set the template_extension attribute,
# depends. This lets users set the template_extension attribute,
# etc. after View.__init__() has already been called.
# etc. after View.__init__() has already been called.
renderer
=
Renderer
(
partials
=
self
.
_
loader
,
renderer
=
Renderer
(
partials
=
self
.
_
partials
,
file_encoding
=
self
.
template_encoding
,
file_encoding
=
self
.
template_encoding
,
search_dirs
=
self
.
template_path
,
search_dirs
=
self
.
template_path
,
file_extension
=
self
.
template_extension
)
file_extension
=
self
.
template_extension
)
...
...
tests/test_view.py
View file @
9d2da6ae
...
@@ -53,7 +53,7 @@ class ViewTestCase(unittest.TestCase):
...
@@ -53,7 +53,7 @@ class ViewTestCase(unittest.TestCase):
"""
"""
template
=
"{{>partial}}"
template
=
"{{>partial}}"
partials
=
{
"partial"
:
"Loaded from dictionary"
}
partials
=
{
"partial"
:
"Loaded from dictionary"
}
view
=
Simple
(
template
=
template
,
loader
=
partials
)
view
=
Simple
(
template
=
template
,
partials
=
partials
)
actual
=
view
.
render
()
actual
=
view
.
render
()
self
.
assertEquals
(
actual
,
"Loaded from dictionary"
)
self
.
assertEquals
(
actual
,
"Loaded from dictionary"
)
...
...
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