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
285f8485
Commit
285f8485
authored
Jan 13, 2012
by
Chris Jerdonek
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Addressed TODO to move regex compilation out of the constructor.
parent
aea32c6e
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
7 additions
and
8 deletions
+7
-8
pystache/renderengine.py
+7
-8
No files found.
pystache/renderengine.py
View file @
285f8485
...
@@ -149,19 +149,17 @@ class RenderEngine(object):
...
@@ -149,19 +149,17 @@ class RenderEngine(object):
if
delimiters
is
None
:
if
delimiters
is
None
:
delimiters
=
DEFAULT_DELIMITERS
delimiters
=
DEFAULT_DELIMITERS
self
.
_delimiters
=
delimiters
self
.
escape
=
escape
self
.
escape
=
escape
self
.
literal
=
literal
self
.
literal
=
literal
self
.
load_partial
=
load_partial
self
.
load_partial
=
load_partial
# TODO: consider an approach that doesn't require compiling a regular
def
_compile_template_re
(
self
):
# expression in the constructor. For example, be lazier. That way
self
.
_template_re
=
_compile_template_re
(
self
.
_delimiters
)
# rendering will still work as expected even if the delimiters are
# set after the constructor
self
.
_set_delimiters
(
delimiters
)
def
_
set
_delimiters
(
self
,
delimiters
):
def
_
change
_delimiters
(
self
,
delimiters
):
self
.
_delimiters
=
delimiters
self
.
_delimiters
=
delimiters
self
.
_
template_re
=
_compile_template_re
(
self
.
_delimiters
)
self
.
_
compile_template_re
(
)
def
render
(
self
,
template
,
context
):
def
render
(
self
,
template
,
context
):
"""
"""
...
@@ -202,6 +200,7 @@ class RenderEngine(object):
...
@@ -202,6 +200,7 @@ class RenderEngine(object):
engine
=
RenderEngine
(
load_partial
=
self
.
load_partial
,
engine
=
RenderEngine
(
load_partial
=
self
.
load_partial
,
literal
=
self
.
literal
,
escape
=
self
.
escape
,
delimiters
=
delims
)
literal
=
self
.
literal
,
escape
=
self
.
escape
,
delimiters
=
delims
)
engine
.
_compile_template_re
()
return
engine
.
parse_to_tree
(
template
=
template_string
)
return
engine
.
parse_to_tree
(
template
=
template_string
)
...
@@ -371,7 +370,7 @@ class RenderEngine(object):
...
@@ -371,7 +370,7 @@ class RenderEngine(object):
if
captures
[
'tag'
]
==
'='
:
if
captures
[
'tag'
]
==
'='
:
delimiters
=
name
.
split
()
delimiters
=
name
.
split
()
self
.
_
set
_delimiters
(
delimiters
)
self
.
_
change
_delimiters
(
delimiters
)
return
end_index
return
end_index
if
captures
[
'tag'
]
==
'>'
:
if
captures
[
'tag'
]
==
'>'
:
...
...
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