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
049a76c1
Commit
049a76c1
authored
May 03, 2012
by
Chris Jerdonek
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added RenderEngine.resolve_context().
parent
69c44762
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
8 additions
and
6 deletions
+8
-6
pystache/parser.py
+1
-1
pystache/renderengine.py
+7
-5
No files found.
pystache/parser.py
View file @
049a76c1
...
...
@@ -215,7 +215,7 @@ class Parser(object):
elif
tag_type
==
'>'
:
template
=
engine
.
re
ad
_partial
(
tag_key
)
template
=
engine
.
re
solve
_partial
(
tag_key
)
# Indent before rendering.
template
=
re
.
sub
(
NON_BLANK_RE
,
leading_whitespace
+
ur'\1'
,
template
)
func
=
engine
.
_make_get_partial
(
template
)
...
...
pystache/renderengine.py
View file @
049a76c1
...
...
@@ -65,8 +65,10 @@ class RenderEngine(object):
self
.
literal
=
literal
self
.
load_partial
=
load_partial
# TODO: rename context to stack throughout this module.
def
read_partial
(
self
,
key
):
def
resolve_context
(
self
,
stack
,
name
):
return
stack
.
get
(
name
)
def
resolve_partial
(
self
,
key
):
try
:
return
self
.
load_partial
(
key
)
except
TemplateNotFoundError
:
...
...
@@ -77,7 +79,7 @@ class RenderEngine(object):
Get a value from the given context as a basestring instance.
"""
val
=
context
.
get
(
tag_name
)
val
=
self
.
resolve_context
(
context
,
tag_name
)
if
callable
(
val
):
# According to the spec:
...
...
@@ -145,7 +147,7 @@ class RenderEngine(object):
"""
# TODO: is there a bug because we are not using the same
# logic as in _get_string_value()?
data
=
context
.
get
(
name
)
data
=
self
.
resolve_context
(
context
,
name
)
# Per the spec, lambdas in inverted sections are considered truthy.
if
data
:
return
u''
...
...
@@ -164,7 +166,7 @@ class RenderEngine(object):
"""
template
=
template_
parsed_template
=
parsed_template_
data
=
context
.
get
(
name
)
data
=
self
.
resolve_context
(
context
,
name
)
# From the spec:
#
...
...
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