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
46ffcc2e
Commit
46ffcc2e
authored
Dec 31, 2011
by
Chris Jerdonek
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Removed an extraneous template argument Template.parse_to_tree().
parent
8d3e051a
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
15 additions
and
14 deletions
+15
-14
pystache/template.py
+15
-14
No files found.
pystache/template.py
View file @
46ffcc2e
...
...
@@ -36,12 +36,12 @@ def call(val, view, template=None):
return
unicode
(
val
)
def
parse
(
template
,
view
,
delims
=
(
'{{'
,
'}}'
)):
t
mpl
=
Template
(
template
)
t
mpl
.
view
=
view
t
mpl
.
otag
,
tmpl
.
ctag
=
delims
t
mpl
.
_compile_regexps
()
return
t
mpl
.
parse_to_tree
(
template
)
def
parse
_to_tree
(
template
,
view
,
delims
=
(
'{{'
,
'}}'
)):
t
emplate
=
Template
(
template
)
t
emplate
.
view
=
view
t
emplate
.
otag
,
template
.
ctag
=
delims
t
emplate
.
_compile_regexps
()
return
t
emplate
.
parse_to_tree
(
)
def
render_parse_tree
(
parse_tree
,
view
,
template
):
get_string
=
lambda
val
:
call
(
val
,
view
,
template
)
...
...
@@ -50,8 +50,8 @@ def render_parse_tree(parse_tree, view, template):
return
''
.
join
(
parts
)
def
render
(
template
,
view
,
delims
=
(
'{{'
,
'}}'
)):
parse
Tree
=
pars
e
(
template
,
view
,
delims
)
return
render_parse_tree
(
parse
T
ree
,
view
,
template
)
parse
_tree
=
parse_to_tre
e
(
template
,
view
,
delims
)
return
render_parse_tree
(
parse
_t
ree
,
view
,
template
)
def
partialTag
(
name
,
indentation
=
''
):
def
func
(
self
):
...
...
@@ -60,14 +60,14 @@ def partialTag(name, indentation=''):
return
render
(
template
,
self
)
return
func
def
sectionTag
(
name
,
parse
d
,
template
,
delims
):
def
sectionTag
(
name
,
parse
_tree_
,
template
,
delims
):
def
func
(
self
):
parse_tree
=
parse_tree_
data
=
self
.
get
(
name
)
ast
=
parsed
if
not
data
:
return
''
elif
callable
(
data
):
ast
=
pars
e
(
call
(
view
=
self
,
val
=
data
,
template
=
template
),
self
,
delims
)
parse_tree
=
parse_to_tre
e
(
call
(
view
=
self
,
val
=
data
,
template
=
template
),
self
,
delims
)
data
=
[
data
]
elif
type
(
data
)
not
in
[
list
,
tuple
]:
data
=
[
data
]
...
...
@@ -75,7 +75,7 @@ def sectionTag(name, parsed, template, delims):
parts
=
[]
for
element
in
data
:
self
.
context_list
.
insert
(
0
,
element
)
parts
.
append
(
render_parse_tree
(
ast
,
self
,
delims
))
parts
.
append
(
render_parse_tree
(
parse_tree
,
self
,
delims
))
del
self
.
context_list
[
0
]
return
''
.
join
(
parts
)
...
...
@@ -138,12 +138,13 @@ class Template(object):
"""
self
.
tag_re
=
re
.
compile
(
tag
%
tags
,
re
.
M
|
re
.
X
)
def
parse_to_tree
(
self
,
template
,
index
=
0
):
def
parse_to_tree
(
self
,
index
=
0
):
"""
Parse a template into a syntax tree.
"""
parse_tree
=
[]
template
=
self
.
template
start_index
=
index
while
True
:
...
...
@@ -199,7 +200,7 @@ class Template(object):
parse_tree
.
append
(
func
)
elif
captures
[
'tag'
]
in
[
'#'
,
'^'
]:
try
:
self
.
parse_to_tree
(
template
,
index
=
end_index
)
self
.
parse_to_tree
(
index
=
end_index
)
except
EndOfSection
as
e
:
bufr
=
e
.
parse_tree
tmpl
=
e
.
template
...
...
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