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
a7e21be2
Commit
a7e21be2
authored
Apr 01, 2012
by
Chris Jerdonek
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
The Renderer class now creates a SpecLoader when necessary.
parent
84b04ad3
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
17 additions
and
5 deletions
+17
-5
pystache/renderer.py
+17
-5
No files found.
pystache/renderer.py
View file @
a7e21be2
...
@@ -9,6 +9,8 @@ from . import defaults
...
@@ -9,6 +9,8 @@ from . import defaults
from
.context
import
Context
from
.context
import
Context
from
.loader
import
Loader
from
.loader
import
Loader
from
.renderengine
import
RenderEngine
from
.renderengine
import
RenderEngine
from
.template_spec
import
SpecLoader
from
.template_spec
import
TemplateSpec
class
Renderer
(
object
):
class
Renderer
(
object
):
...
@@ -250,7 +252,17 @@ class Renderer(object):
...
@@ -250,7 +252,17 @@ class Renderer(object):
"""
"""
loader
=
self
.
_make_loader
()
loader
=
self
.
_make_loader
()
template
=
loader
.
load_object
(
obj
)
# TODO: consider an approach that does not require using an if
# block here. For example, perhaps this class's loader can be
# a SpecLoader in all cases, and the SpecLoader instance can
# check the object's type. Or perhaps Loader and SpecLoader
# can be refactored to implement the same interface.
if
isinstance
(
obj
,
TemplateSpec
):
loader
=
SpecLoader
(
loader
)
template
=
loader
.
load
(
obj
)
else
:
template
=
loader
.
load_object
(
obj
)
context
=
[
obj
]
+
list
(
context
)
context
=
[
obj
]
+
list
(
context
)
...
@@ -299,8 +311,8 @@ class Renderer(object):
...
@@ -299,8 +311,8 @@ class Renderer(object):
all items in the *context list.
all items in the *context list.
"""
"""
if
not
isinstance
(
template
,
basestring
):
if
isinstance
(
template
,
basestring
):
# Then we assume the template is an object.
return
self
.
_render_string
(
template
,
*
context
,
**
kwargs
)
return
self
.
_render_object
(
template
,
*
context
,
**
kwargs
)
# Otherwise, we assume the template is an object.
return
self
.
_render_
string
(
template
,
*
context
,
**
kwargs
)
return
self
.
_render_
object
(
template
,
*
context
,
**
kwargs
)
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