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
24907457
Commit
24907457
authored
Jan 01, 2012
by
Chris Jerdonek
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Changed the order of a couple methods in RenderEngine.
parent
8ff50e0b
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
31 additions
and
29 deletions
+31
-29
pystache/renderengine.py
+31
-29
No files found.
pystache/renderengine.py
View file @
24907457
...
...
@@ -159,7 +159,35 @@ class RenderEngine(object):
# don't use self.literal).
template
=
unicode
(
template
)
return
self
.
render_template
(
template
=
template
,
context
=
context
)
return
self
.
_render_template
(
template
=
template
,
context
=
context
)
def
_render_template
(
self
,
template
,
context
):
"""
Arguments:
template: template string
context: a Context instance
"""
if
type
(
template
)
is
not
unicode
:
raise
Exception
(
"Argument 'template' not unicode:
%
s:
%
s"
%
(
type
(
template
),
repr
(
template
)))
parse_tree
=
self
.
parse_string_to_tree
(
template_string
=
template
)
return
render_parse_tree
(
parse_tree
,
context
,
template
)
def
parse_string_to_tree
(
self
,
template_string
,
delims
=
None
):
engine
=
RenderEngine
(
load_partial
=
self
.
load_partial
,
literal
=
self
.
literal
,
escape
=
self
.
escape
)
if
delims
is
not
None
:
engine
.
otag
=
delims
[
0
]
engine
.
ctag
=
delims
[
1
]
engine
.
_compile_regexps
()
return
engine
.
parse_to_tree
(
template
=
template_string
)
def
_compile_regexps
(
self
):
...
...
@@ -216,7 +244,7 @@ class RenderEngine(object):
template
=
str
(
template
)
if
type
(
template
)
is
not
unicode
:
template
=
self
.
literal
(
template
)
val
=
self
.
render_template
(
template
,
context
)
val
=
self
.
_
render_template
(
template
,
context
)
if
not
isinstance
(
val
,
basestring
):
val
=
str
(
val
)
...
...
@@ -245,7 +273,7 @@ class RenderEngine(object):
template
=
self
.
load_partial
(
name
)
# Indent before rendering.
template
=
re
.
sub
(
nonblank
,
indentation
+
r'\1'
,
template
)
return
self
.
render_template
(
template
,
context
)
return
self
.
_
render_template
(
template
,
context
)
return
func
def
section_tag_function
(
self
,
name
,
parse_tree_
,
template_
,
delims
):
...
...
@@ -272,18 +300,6 @@ class RenderEngine(object):
return
''
.
join
(
parts
)
return
func
def
parse_string_to_tree
(
self
,
template_string
,
delims
=
None
):
engine
=
RenderEngine
(
load_partial
=
self
.
load_partial
,
literal
=
self
.
literal
,
escape
=
self
.
escape
)
if
delims
is
not
None
:
engine
.
otag
=
delims
[
0
]
engine
.
ctag
=
delims
[
1
]
engine
.
_compile_regexps
()
return
engine
.
parse_to_tree
(
template
=
template_string
)
def
parse_to_tree
(
self
,
template
,
index
=
0
):
"""
Parse a template into a syntax tree.
...
...
@@ -379,17 +395,3 @@ class RenderEngine(object):
return
end_index
def
render_template
(
self
,
template
,
context
):
"""
Arguments:
template: template string
context: a Context instance
"""
if
type
(
template
)
is
not
unicode
:
raise
Exception
(
"Argument 'template' not unicode:
%
s:
%
s"
%
(
type
(
template
),
repr
(
template
)))
parse_tree
=
self
.
parse_string_to_tree
(
template_string
=
template
)
return
render_parse_tree
(
parse_tree
,
context
,
template
)
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