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
d6880870
Commit
d6880870
authored
Jan 14, 2012
by
Chris Jerdonek
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Created _parse_section() method.
parent
a3141ab8
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
16 additions
and
10 deletions
+16
-10
pystache/parser.py
+16
-10
No files found.
pystache/parser.py
View file @
d6880870
...
...
@@ -40,10 +40,11 @@ def _compile_template_re(delimiters):
class
EndOfSection
(
Exception
):
def
__init__
(
self
,
parse_tree
,
template
,
position
):
def
__init__
(
self
,
parse_tree
,
template
,
index_end
):
self
.
parse_tree
=
parse_tree
self
.
template
=
template
self
.
position
=
position
self
.
index_end
=
index_end
class
Parser
(
object
):
...
...
@@ -132,6 +133,16 @@ class Parser(object):
return
parse_tree
def
_parse_section
(
self
,
template
,
index_start
):
try
:
self
.
parse
(
template
=
template
,
index
=
index_start
)
except
EndOfSection
as
err
:
buff
=
err
.
parse_tree
template
=
err
.
template
index_end
=
err
.
index_end
return
buff
,
template
,
index_end
def
_handle_match
(
self
,
template
,
parse_tree
,
tag_type
,
tag_key
,
leading_whitespace
,
start_index
,
match_index
,
end_index
):
if
tag_type
==
'!'
:
...
...
@@ -148,17 +159,12 @@ class Parser(object):
func
=
engine
.
_make_get_partial
(
tag_key
,
leading_whitespace
)
elif
tag_type
in
[
'#'
,
'^'
]:
try
:
self
.
parse
(
template
=
template
,
index
=
end_index
)
except
EndOfSection
as
e
:
bufr
=
e
.
parse_tree
tmpl
=
e
.
template
end_index
=
e
.
position
buff
,
template
,
end_index
=
self
.
_parse_section
(
template
,
end_index
)
if
tag_type
==
'#'
:
func
=
engine
.
_make_get_section
(
tag_key
,
buf
r
,
tmpl
,
self
.
_delimiters
)
func
=
engine
.
_make_get_section
(
tag_key
,
buf
f
,
template
,
self
.
_delimiters
)
else
:
func
=
engine
.
_make_get_inverse
(
tag_key
,
buf
r
)
func
=
engine
.
_make_get_inverse
(
tag_key
,
buf
f
)
elif
tag_type
==
'&'
:
...
...
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