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
c7007a70
Commit
c7007a70
authored
Jan 01, 2012
by
Chris Jerdonek
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
The Template class no longer has a template attribute.
parent
47f24b4e
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
10 additions
and
15 deletions
+10
-15
pystache/renderengine.py
+10
-15
No files found.
pystache/renderengine.py
View file @
c7007a70
...
...
@@ -155,7 +155,7 @@ class RenderEngine(object):
# don't use self.literal).
template
=
unicode
(
template
)
_template
=
Template
(
template
=
template
)
_template
=
Template
()
_template
.
to_unicode
=
self
.
literal
_template
.
escape
=
self
.
escape
...
...
@@ -168,9 +168,6 @@ class Template(object):
tag_re
=
None
otag
,
ctag
=
'{{'
,
'}}'
def
__init__
(
self
,
template
=
None
):
self
.
template
=
template
def
_compile_regexps
(
self
):
# The possible tag type characters following the opening tag,
...
...
@@ -277,7 +274,7 @@ class Template(object):
elif
callable
(
data
):
# TODO: should we check the arity?
template
=
data
(
template
)
parse_tree
=
self
.
parse_string_to_tree
(
template
,
delims
)
parse_tree
=
self
.
parse_string_to_tree
(
template
_string
=
template
,
delims
=
delims
)
data
=
[
data
]
elif
type
(
data
)
not
in
[
list
,
tuple
]:
data
=
[
data
]
...
...
@@ -291,9 +288,9 @@ class Template(object):
return
''
.
join
(
parts
)
return
func
def
parse_string_to_tree
(
self
,
template
,
delims
=
(
'{{'
,
'}}'
)):
def
parse_string_to_tree
(
self
,
template
_string
,
delims
=
(
'{{'
,
'}}'
)):
template
=
Template
(
template
)
template
=
Template
()
template
.
otag
=
delims
[
0
]
template
.
ctag
=
delims
[
1
]
...
...
@@ -304,15 +301,14 @@ class Template(object):
template
.
_compile_regexps
()
return
template
.
parse_to_tree
()
return
template
.
parse_to_tree
(
template
=
template_string
)
def
parse_to_tree
(
self
,
index
=
0
):
def
parse_to_tree
(
self
,
template
,
index
=
0
):
"""
Parse a template into a syntax tree.
"""
parse_tree
=
[]
template
=
self
.
template
start_index
=
index
while
True
:
...
...
@@ -325,15 +321,14 @@ class Template(object):
match_index
=
match
.
end
(
'content'
)
end_index
=
match
.
end
()
index
=
self
.
_handle_match
(
parse_tree
,
captures
,
start_index
,
match_index
,
end_index
)
index
=
self
.
_handle_match
(
template
,
parse_tree
,
captures
,
start_index
,
match_index
,
end_index
)
# Save the rest of the template.
parse_tree
.
append
(
template
[
index
:])
return
parse_tree
def
_handle_match
(
self
,
parse_tree
,
captures
,
start_index
,
match_index
,
end_index
):
template
=
self
.
template
def
_handle_match
(
self
,
template
,
parse_tree
,
captures
,
start_index
,
match_index
,
end_index
):
# Normalize the captures dictionary.
if
captures
[
'change'
]
is
not
None
:
...
...
@@ -374,7 +369,7 @@ class Template(object):
elif
captures
[
'tag'
]
in
[
'#'
,
'^'
]:
try
:
self
.
parse_to_tree
(
index
=
end_index
)
self
.
parse_to_tree
(
template
=
template
,
index
=
end_index
)
except
EndOfSection
as
e
:
bufr
=
e
.
parse_tree
tmpl
=
e
.
template
...
...
@@ -414,6 +409,6 @@ class Template(object):
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
=
template
,
delims
=
delims
)
parse_tree
=
self
.
parse_string_to_tree
(
template
_string
=
template
,
delims
=
delims
)
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