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
331a48d0
Commit
331a48d0
authored
May 06, 2012
by
Chris Jerdonek
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ParsedTemplate docstring udpates and removed RenderEngine.render_parsed().
parent
8f9da1a7
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
12 additions
and
27 deletions
+12
-27
pystache/parsed.py
+9
-21
pystache/parser.py
+2
-2
pystache/renderengine.py
+1
-4
No files found.
pystache/parsed.py
View file @
331a48d0
...
...
@@ -3,39 +3,27 @@
"""
Exposes a class that represents a parsed (or compiled) template.
This module is meant only for internal use.
"""
class
ParsedTemplate
(
object
):
def
__init__
(
self
):
"""
Arguments:
parse_tree: a list, each element of which is either--
(1) a unicode string, or
(2) a "rendering" callable that accepts a ContextStack instance
and returns a unicode string.
The possible rendering callables are the return values of the
following functions:
* RenderEngine._make_get_escaped()
* RenderEngine._make_get_inverse()
* RenderEngine._make_get_literal()
* RenderEngine._make_get_partial()
* RenderEngine._make_get_section()
"""
self
.
_parse_tree
=
[]
def
__repr__
(
self
):
return
repr
(
self
.
_parse_tree
)
def
add
(
self
,
node
):
"""
Arguments:
node: a unicode string or node object instance. A node object
instance must have a `render(engine, stack)` method that
accepts a RenderEngine instance and a ContextStack instance and
returns a unicode string.
"""
self
.
_parse_tree
.
append
(
node
)
def
render
(
self
,
engine
,
context
):
...
...
pystache/parser.py
View file @
331a48d0
...
...
@@ -166,7 +166,7 @@ class _InvertedNode(object):
# per the spec.
if
data
:
return
u''
return
engine
.
render_parsed
(
self
.
parsed_section
,
context
)
return
self
.
parsed_section
.
render
(
engine
,
context
)
class
_SectionNode
(
object
):
...
...
@@ -212,7 +212,7 @@ class _SectionNode(object):
continue
context
.
push
(
val
)
parts
.
append
(
engine
.
render_parsed
(
self
.
parsed
,
context
))
parts
.
append
(
self
.
parsed
.
render
(
engine
,
context
))
context
.
pop
()
return
unicode
(
''
.
join
(
parts
))
...
...
pystache/renderengine.py
View file @
331a48d0
...
...
@@ -150,9 +150,6 @@ class RenderEngine(object):
val
=
self
.
literal
(
val
)
return
self
.
render
(
val
,
context
,
delimiters
)
def
render_parsed
(
self
,
parsed_template
,
context_stack
):
return
parsed_template
.
render
(
self
,
context_stack
)
def
render
(
self
,
template
,
context_stack
,
delimiters
=
None
):
"""
Render a unicode template string, and return as unicode.
...
...
@@ -167,4 +164,4 @@ class RenderEngine(object):
"""
parsed_template
=
parse
(
template
,
delimiters
)
return
self
.
render_parsed
(
parsed_template
,
context_stack
)
return
parsed_template
.
render
(
self
,
context_stack
)
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