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
4f85f1f0
Commit
4f85f1f0
authored
May 05, 2012
by
Chris Jerdonek
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Created _make_interpolation_node() and _make_section_node().
parent
a6105f89
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
19 additions
and
10 deletions
+19
-10
pystache/parser.py
+19
-10
No files found.
pystache/parser.py
View file @
4f85f1f0
...
...
@@ -154,20 +154,22 @@ class Parser(object):
continue
start_index
=
end_index
if
tag_type
==
'/'
:
if
tag_key
!=
section_key
:
raise
ParsingError
(
"Section end tag mismatch:
%
s !=
%
s"
%
(
tag_key
,
section_key
))
# Restore previous state with newly found section data.
start_index
,
content_end_index
,
parsed_section
=
end_index
,
match_index
,
parsed_template
content_end_index
,
parsed_section
=
match_index
,
parsed_template
(
tag_type
,
tag_key
,
leading_whitespace
,
end_index
,
section_key
,
parsed_template
)
=
states
.
pop
()
node
=
self
.
_make_section_node
(
template
,
tag_type
,
tag_key
,
parsed_section
,
end_index
,
content_end_index
)
else
:
start_index
=
end_index
node
=
self
.
_make_interpolation_node
(
tag_type
,
tag_key
,
leading_whitespace
)
node
=
self
.
_make_node
(
template
,
tag_type
,
tag_key
,
leading_whitespace
,
end_index
,
content_end_index
,
parsed_section
)
parsed_template
.
add
(
node
)
# Save the rest of the template.
...
...
@@ -175,8 +177,7 @@ class Parser(object):
return
parsed_template
def
_make_node
(
self
,
template
,
tag_type
,
tag_key
,
leading_whitespace
,
section_start_index
,
section_end_index
,
parsed_section
):
def
_make_interpolation_node
(
self
,
tag_type
,
tag_key
,
leading_whitespace
):
"""
Create and return a node of the parse tree.
...
...
@@ -196,6 +197,17 @@ class Parser(object):
if
tag_type
==
'&'
:
return
self
.
engine
.
_make_get_literal
(
tag_key
)
if
tag_type
==
'>'
:
return
self
.
engine
.
_make_get_partial
(
tag_key
,
leading_whitespace
)
raise
Exception
(
"Invalid symbol for interpolation tag:
%
s"
%
repr
(
tag_type
))
def
_make_section_node
(
self
,
template
,
tag_type
,
tag_key
,
parsed_section
,
section_start_index
,
section_end_index
):
"""
Create and return a node of the parse tree.
"""
if
tag_type
==
'#'
:
return
self
.
engine
.
_make_get_section
(
tag_key
,
parsed_section
,
self
.
_delimiters
,
template
,
section_start_index
,
section_end_index
)
...
...
@@ -203,7 +215,4 @@ class Parser(object):
if
tag_type
==
'^'
:
return
self
.
engine
.
_make_get_inverse
(
tag_key
,
parsed_section
)
if
tag_type
==
'>'
:
return
self
.
engine
.
_make_get_partial
(
tag_key
,
leading_whitespace
)
raise
Exception
(
"Unrecognized tag type:
%
s"
%
repr
(
tag_type
))
raise
Exception
(
"Invalid symbol for section tag:
%
s"
%
repr
(
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