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
b5ed8a69
Commit
b5ed8a69
authored
Jan 13, 2012
by
Chris Jerdonek
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Renamed the "captures" local variable to "matches".
parent
285f8485
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
25 additions
and
25 deletions
+25
-25
pystache/renderengine.py
+25
-25
No files found.
pystache/renderengine.py
View file @
b5ed8a69
...
...
@@ -326,56 +326,56 @@ class RenderEngine(object):
if
match
is
None
:
break
captur
es
=
match
.
groupdict
()
match
es
=
match
.
groupdict
()
match_index
=
match
.
end
(
'content'
)
end_index
=
match
.
end
()
index
=
self
.
_handle_match
(
template
,
parse_tree
,
captur
es
,
start_index
,
match_index
,
end_index
)
index
=
self
.
_handle_match
(
template
,
parse_tree
,
match
es
,
start_index
,
match_index
,
end_index
)
# Save the rest of the template.
parse_tree
.
append
(
template
[
index
:])
return
parse_tree
def
_handle_match
(
self
,
template
,
parse_tree
,
captur
es
,
start_index
,
match_index
,
end_index
):
def
_handle_match
(
self
,
template
,
parse_tree
,
match
es
,
start_index
,
match_index
,
end_index
):
# Normalize the
captur
es dictionary.
if
captur
es
[
'change'
]
is
not
None
:
captures
.
update
(
tag
=
'='
,
name
=
captur
es
[
'delims'
])
elif
captur
es
[
'raw'
]
is
not
None
:
captures
.
update
(
tag
=
'{'
,
name
=
captur
es
[
'raw_name'
])
# Normalize the
match
es dictionary.
if
match
es
[
'change'
]
is
not
None
:
matches
.
update
(
tag
=
'='
,
name
=
match
es
[
'delims'
])
elif
match
es
[
'raw'
]
is
not
None
:
matches
.
update
(
tag
=
'{'
,
name
=
match
es
[
'raw_name'
])
parse_tree
.
append
(
captur
es
[
'content'
])
parse_tree
.
append
(
match
es
[
'content'
])
# Standalone (non-interpolation) tags consume the entire line,
# both leading whitespace and trailing newline.
did_tag_begin_line
=
match_index
==
0
or
template
[
match_index
-
1
]
in
END_OF_LINE_CHARACTERS
did_tag_end_line
=
end_index
==
len
(
template
)
or
template
[
end_index
]
in
END_OF_LINE_CHARACTERS
is_tag_interpolating
=
captur
es
[
'tag'
]
in
[
''
,
'&'
,
'{'
]
is_tag_interpolating
=
match
es
[
'tag'
]
in
[
''
,
'&'
,
'{'
]
if
did_tag_begin_line
and
did_tag_end_line
and
not
is_tag_interpolating
:
if
end_index
<
len
(
template
):
end_index
+=
template
[
end_index
]
==
'
\r
'
and
1
or
0
if
end_index
<
len
(
template
):
end_index
+=
template
[
end_index
]
==
'
\n
'
and
1
or
0
elif
captur
es
[
'whitespace'
]:
parse_tree
.
append
(
captur
es
[
'whitespace'
])
match_index
+=
len
(
captur
es
[
'whitespace'
])
captur
es
[
'whitespace'
]
=
''
elif
match
es
[
'whitespace'
]:
parse_tree
.
append
(
match
es
[
'whitespace'
])
match_index
+=
len
(
match
es
[
'whitespace'
])
match
es
[
'whitespace'
]
=
''
name
=
captur
es
[
'name'
]
name
=
match
es
[
'name'
]
if
captur
es
[
'tag'
]
==
'!'
:
if
match
es
[
'tag'
]
==
'!'
:
return
end_index
if
captur
es
[
'tag'
]
==
'='
:
if
match
es
[
'tag'
]
==
'='
:
delimiters
=
name
.
split
()
self
.
_change_delimiters
(
delimiters
)
return
end_index
if
captur
es
[
'tag'
]
==
'>'
:
func
=
self
.
_make_get_partial
(
name
,
captur
es
[
'whitespace'
])
elif
captur
es
[
'tag'
]
in
[
'#'
,
'^'
]:
if
match
es
[
'tag'
]
==
'>'
:
func
=
self
.
_make_get_partial
(
name
,
match
es
[
'whitespace'
])
elif
match
es
[
'tag'
]
in
[
'#'
,
'^'
]:
try
:
self
.
parse_to_tree
(
template
=
template
,
index
=
end_index
)
...
...
@@ -384,26 +384,26 @@ class RenderEngine(object):
tmpl
=
e
.
template
end_index
=
e
.
position
if
captur
es
[
'tag'
]
==
'#'
:
if
match
es
[
'tag'
]
==
'#'
:
func
=
self
.
_make_get_section
(
name
,
bufr
,
tmpl
,
self
.
_delimiters
)
else
:
func
=
_make_get_inverse
(
name
,
bufr
)
elif
captur
es
[
'tag'
]
in
[
'{'
,
'&'
]:
elif
match
es
[
'tag'
]
in
[
'{'
,
'&'
]:
func
=
self
.
_make_get_literal
(
name
)
elif
captur
es
[
'tag'
]
==
''
:
elif
match
es
[
'tag'
]
==
''
:
func
=
self
.
_make_get_escaped
(
name
)
elif
captur
es
[
'tag'
]
==
'/'
:
elif
match
es
[
'tag'
]
==
'/'
:
# TODO: don't use exceptions for flow control.
raise
EndOfSection
(
parse_tree
,
template
[
start_index
:
match_index
],
end_index
)
else
:
raise
Exception
(
"'
%
s' is an unrecognized type!"
%
captur
es
[
'tag'
])
raise
Exception
(
"'
%
s' is an unrecognized type!"
%
match
es
[
'tag'
])
parse_tree
.
append
(
func
)
...
...
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