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
ef3ef4bf
Commit
ef3ef4bf
authored
May 04, 2012
by
Chris Jerdonek
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Refactored some of the parsing logic: delayed template slicing.
parent
1a9ca1f7
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
10 additions
and
9 deletions
+10
-9
pystache/parser.py
+7
-5
pystache/renderengine.py
+3
-4
No files found.
pystache/parser.py
View file @
ef3ef4bf
...
...
@@ -177,10 +177,10 @@ class Parser(object):
including any trailing newlines).
"""
parsed_section
,
content
_end_index
,
end_index
=
\
parsed_section
,
section
_end_index
,
end_index
=
\
self
.
parse
(
template
=
template
,
start_index
=
start_index
,
section_key
=
section_key
)
return
parsed_section
,
template
[
start_index
:
content_end_index
]
,
end_index
return
parsed_section
,
section_end_index
,
end_index
def
_handle_tag_type
(
self
,
template
,
parse_tree
,
tag_type
,
tag_key
,
leading_whitespace
,
end_index
):
...
...
@@ -205,12 +205,14 @@ class Parser(object):
elif
tag_type
==
'#'
:
parsed_section
,
section_contents
,
end_index
=
self
.
_parse_section
(
template
,
end_index
,
tag_key
)
func
=
engine
.
_make_get_section
(
tag_key
,
parsed_section
,
section_contents
,
self
.
_delimiters
)
section_start_index
=
end_index
parsed_section
,
section_end_index
,
end_index
=
self
.
_parse_section
(
template
,
end_index
,
tag_key
)
func
=
engine
.
_make_get_section
(
tag_key
,
parsed_section
,
self
.
_delimiters
,
template
,
section_start_index
,
section_end_index
)
elif
tag_type
==
'^'
:
parsed_section
,
section_
contents
,
end_index
=
self
.
_parse_section
(
template
,
end_index
,
tag_key
)
parsed_section
,
section_
end_index
,
end_index
=
self
.
_parse_section
(
template
,
end_index
,
tag_key
)
func
=
engine
.
_make_get_inverse
(
tag_key
,
parsed_section
)
elif
tag_type
==
'>'
:
...
...
pystache/renderengine.py
View file @
ef3ef4bf
...
...
@@ -162,14 +162,13 @@ class RenderEngine(object):
# TODO: the template_ and parsed_template_ arguments don't both seem
# to be necessary. Can we remove one of them? For example, if
# callable(data) is True, then the initial parsed_template isn't used.
def
_make_get_section
(
self
,
name
,
parsed_template_
,
template_
,
delims
):
def
_make_get_section
(
self
,
name
,
parsed_template
,
delims
,
template
,
section_start_index
,
section_end_index
):
def
get_section
(
context
):
"""
Returns: a string of type unicode.
"""
template
=
template_
parsed_template
=
parsed_template_
data
=
self
.
resolve_context
(
context
,
name
)
# From the spec:
...
...
@@ -220,7 +219,7 @@ class RenderEngine(object):
# https://github.com/defunkt/pystache/issues/113
#
# TODO: should we check the arity?
new_template
=
element
(
template
)
new_template
=
element
(
template
[
section_start_index
:
section_end_index
]
)
new_parsed_template
=
self
.
_parse
(
new_template
,
delimiters
=
delims
)
parts
.
append
(
new_parsed_template
.
render
(
context
))
continue
...
...
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