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
f26c5e7a
Commit
f26c5e7a
authored
Jan 21, 2012
by
Chris Jerdonek
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Moved some of the partial logic from RenderEngine to Parser.
parent
792ce17d
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
9 additions
and
8 deletions
+9
-8
pystache/parser.py
+8
-1
pystache/renderengine.py
+1
-7
No files found.
pystache/parser.py
View file @
f26c5e7a
...
...
@@ -14,6 +14,7 @@ from template import ParsedTemplate
DEFAULT_DELIMITERS
=
(
'{{'
,
'}}'
)
END_OF_LINE_CHARACTERS
=
[
'
\r
'
,
'
\n
'
]
NON_BLANK_RE
=
re
.
compile
(
r'^(.)'
,
re
.
M
)
def
_compile_template_re
(
delimiters
):
...
...
@@ -148,6 +149,7 @@ class Parser(object):
def
_handle_tag_type
(
self
,
template
,
parse_tree
,
tag_type
,
tag_key
,
leading_whitespace
,
end_index
):
# TODO: switch to using a dictionary instead of a bunch of ifs and elifs.
if
tag_type
==
'!'
:
return
end_index
...
...
@@ -178,7 +180,12 @@ class Parser(object):
elif
tag_type
==
'>'
:
func
=
engine
.
_make_get_partial
(
tag_key
,
leading_whitespace
)
template
=
engine
.
load_partial
(
tag_key
)
# Indent before rendering.
template
=
re
.
sub
(
NON_BLANK_RE
,
leading_whitespace
+
r'\1'
,
template
)
func
=
engine
.
_make_get_partial
(
template
)
else
:
...
...
pystache/renderengine.py
View file @
f26c5e7a
...
...
@@ -10,9 +10,6 @@ import re
from
parser
import
Parser
NON_BLANK_RE
=
re
.
compile
(
r'^(.)'
,
re
.
M
)
class
RenderEngine
(
object
):
"""
...
...
@@ -129,15 +126,12 @@ class RenderEngine(object):
return
get_escaped
def
_make_get_partial
(
self
,
name
,
indentation
=
''
):
def
_make_get_partial
(
self
,
template
):
def
get_partial
(
context
):
"""
Returns: a string of type unicode.
"""
template
=
self
.
load_partial
(
name
)
# Indent before rendering.
template
=
re
.
sub
(
NON_BLANK_RE
,
indentation
+
r'\1'
,
template
)
return
self
.
_render
(
template
,
context
)
return
get_partial
...
...
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