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
a936076f
Commit
a936076f
authored
Dec 09, 2011
by
Jake Archibald
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Preventing section content being processed as a template. Fixes #46
parent
1609163f
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
12 additions
and
5 deletions
+12
-5
pystache/template.py
+12
-5
No files found.
pystache/template.py
View file @
a936076f
...
...
@@ -68,7 +68,8 @@ class Template(object):
tag
=
r"
%(otag)
s(#|=|&|!|>|\{)?(.+?)\1?
%(ctag)
s+"
self
.
tag_re
=
re
.
compile
(
tag
%
tags
)
def
_render_sections
(
self
,
template
,
view
):
def
_render
(
self
,
template
,
view
):
output
=
''
while
True
:
match
=
self
.
section_re
.
search
(
template
)
if
match
is
None
:
...
...
@@ -98,9 +99,15 @@ class Template(object):
elif
(
not
it
and
section
[
2
]
==
'^'
)
or
(
it
and
section
[
2
]
!=
'^'
):
replacer
=
self
.
_render_dictionary
(
inner
,
it
)
template
=
literal
(
template
.
replace
(
section
,
replacer
))
# Render template prior to section too
output
=
output
+
self
.
_render_tags
(
template
[
0
:
match
.
start
()])
+
replacer
template
=
template
[
match
.
end
():]
return
template
# Render remainder
output
=
output
+
self
.
_render_tags
(
template
)
return
output
def
_render_tags
(
self
,
template
):
output
=
''
...
...
@@ -172,8 +179,8 @@ class Template(object):
return
literal
(
self
.
view
.
get
(
tag_name
,
''
))
def
render
(
self
,
encoding
=
None
):
template
=
self
.
_render_sections
(
self
.
template
,
self
.
view
)
result
=
self
.
_render_tags
(
template
)
result
=
self
.
_render
(
self
.
template
,
self
.
view
)
#
result = self._render_tags(template)
if
encoding
is
not
None
:
result
=
result
.
encode
(
encoding
)
...
...
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