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
b4f6f97d
Commit
b4f6f97d
authored
Dec 31, 2011
by
Chris Jerdonek
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Renamed buffer to parse_tree.
parent
9613e386
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
11 additions
and
11 deletions
+11
-11
pystache/template.py
+11
-11
No files found.
pystache/template.py
View file @
b4f6f97d
...
...
@@ -98,8 +98,8 @@ def unescapedTag(name, delims):
return
func
class
EndOfSection
(
Exception
):
def
__init__
(
self
,
buffer
,
template
,
position
):
self
.
buffer
=
buffer
def
__init__
(
self
,
parse_tree
,
template
,
position
):
self
.
parse_tree
=
parse_tree
self
.
template
=
template
self
.
position
=
position
...
...
@@ -154,7 +154,7 @@ class Template(object):
return
parse_tree
def
_handle_match
(
self
,
template
,
match
,
buffer
,
start_index
):
def
_handle_match
(
self
,
template
,
match
,
parse_tree
,
start_index
):
# Normalize the captures dictionary.
captures
=
match
.
groupdict
()
if
captures
[
'change'
]
is
not
None
:
...
...
@@ -163,7 +163,7 @@ class Template(object):
captures
.
update
(
tag
=
'{'
,
name
=
captures
[
'raw_name'
])
# Save the literal text content.
buffer
.
append
(
captures
[
'content'
])
parse_tree
.
append
(
captures
[
'content'
])
end_index
=
match
.
end
()
match_index
=
match
.
end
(
'content'
)
...
...
@@ -179,7 +179,7 @@ class Template(object):
if
end_index
<
len
(
template
):
end_index
+=
template
[
end_index
]
==
'
\n
'
and
1
or
0
elif
captures
[
'whitespace'
]:
buffer
.
append
(
captures
[
'whitespace'
])
parse_tree
.
append
(
captures
[
'whitespace'
])
match_index
+=
len
(
captures
[
'whitespace'
])
captures
[
'whitespace'
]
=
''
...
...
@@ -190,23 +190,23 @@ class Template(object):
self
.
otag
,
self
.
ctag
=
name
.
split
()
self
.
_compile_regexps
()
elif
captures
[
'tag'
]
==
'>'
:
buffer
.
append
(
partialTag
(
name
,
captures
[
'whitespace'
]))
parse_tree
.
append
(
partialTag
(
name
,
captures
[
'whitespace'
]))
elif
captures
[
'tag'
]
in
[
'#'
,
'^'
]:
try
:
self
.
parse_to_tree
(
template
,
index
=
end_index
)
except
EndOfSection
as
e
:
bufr
=
e
.
buffer
bufr
=
e
.
parse_tree
tmpl
=
e
.
template
end_index
=
e
.
position
tag
=
{
'#'
:
sectionTag
,
'^'
:
inverseTag
}[
captures
[
'tag'
]]
buffer
.
append
(
tag
(
name
,
bufr
,
tmpl
,
(
self
.
otag
,
self
.
ctag
)))
parse_tree
.
append
(
tag
(
name
,
bufr
,
tmpl
,
(
self
.
otag
,
self
.
ctag
)))
elif
captures
[
'tag'
]
==
'/'
:
raise
EndOfSection
(
buffer
,
template
[
start_index
:
match_index
],
end_index
)
raise
EndOfSection
(
parse_tree
,
template
[
start_index
:
match_index
],
end_index
)
elif
captures
[
'tag'
]
in
[
'{'
,
'&'
]:
buffer
.
append
(
unescapedTag
(
name
,
(
self
.
otag
,
self
.
ctag
)))
parse_tree
.
append
(
unescapedTag
(
name
,
(
self
.
otag
,
self
.
ctag
)))
elif
captures
[
'tag'
]
==
''
:
buffer
.
append
(
escapedTag
(
name
,
(
self
.
otag
,
self
.
ctag
)))
parse_tree
.
append
(
escapedTag
(
name
,
(
self
.
otag
,
self
.
ctag
)))
else
:
raise
Exception
(
"'
%
s' is an unrecognized type!"
%
captures
[
'tag'
])
...
...
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