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
3e23a0c1
Commit
3e23a0c1
authored
May 04, 2012
by
Chris Jerdonek
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Tweaks to renderengine.py.
parent
b001ae77
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
15 additions
and
15 deletions
+15
-15
pystache/renderengine.py
+15
-15
No files found.
pystache/renderengine.py
View file @
3e23a0c1
...
...
@@ -78,6 +78,14 @@ class RenderEngine(object):
self
.
resolve_partial
=
resolve_partial
# TODO: Rename context to stack throughout this module.
# From the spec:
#
# When used as the data value for an Interpolation tag, the lambda
# MUST be treatable as an arity 0 function, and invoked as such.
# The returned value MUST be rendered against the default delimiters,
# then interpolated in place of the lambda.
#
def
_get_string_value
(
self
,
context
,
tag_name
):
"""
Get a value from the given context as a basestring instance.
...
...
@@ -86,17 +94,11 @@ class RenderEngine(object):
val
=
self
.
resolve_context
(
context
,
tag_name
)
if
callable
(
val
):
# According to the spec:
#
# When used as the data value for an Interpolation tag,
# the lambda MUST be treatable as an arity 0 function,
# and invoked as such. The returned value MUST be
# rendered against the default delimiters, then
# interpolated in place of the lambda.
val
=
self
.
_render_value
(
val
(),
context
)
# Return because _render_value() is already a string.
return
self
.
_render_value
(
val
(),
context
)
if
not
isinstance
(
val
,
basestring
):
val
=
str
(
val
)
return
str
(
val
)
return
val
...
...
@@ -107,8 +109,7 @@ class RenderEngine(object):
"""
s
=
self
.
_get_string_value
(
context
,
name
)
s
=
self
.
literal
(
s
)
return
s
return
self
.
literal
(
s
)
return
get_literal
...
...
@@ -121,8 +122,7 @@ class RenderEngine(object):
"""
s
=
self
.
_get_string_value
(
context
,
name
)
s
=
self
.
escape
(
s
)
return
s
return
self
.
escape
(
s
)
return
get_escaped
...
...
@@ -158,7 +158,7 @@ class RenderEngine(object):
# callable(data) is True, then the initial parsed_template isn't used.
def
_make_get_section
(
self
,
name
,
parsed_template
,
delims
,
template
,
section_start_index
,
section_end_index
):
def
get_section
(
context
):
def
get_section
_value
(
context
):
"""
Returns: a string of type unicode.
...
...
@@ -224,7 +224,7 @@ class RenderEngine(object):
return
unicode
(
''
.
join
(
parts
))
return
get_section
return
get_section
_value
def
_parse
(
self
,
template
,
delimiters
=
None
):
"""
...
...
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