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
a15519f4
Commit
a15519f4
authored
Mar 30, 2010
by
Chris Wanstrath
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add {{& blah}} as an alias for {{{ blah }}}
parent
04560aca
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
8 additions
and
1 deletions
+8
-1
pystache/template.py
+2
-1
tests/test_examples.py
+6
-0
No files found.
pystache/template.py
View file @
a15519f4
...
...
@@ -52,7 +52,7 @@ class Template(object):
section
=
r"
%(otag)
s\#([^\}]*)
%(ctag)
s\s*(.+?)\s*
%(otag)
s/\1
%(ctag)
s"
self
.
section_re
=
re
.
compile
(
section
%
tags
,
re
.
M
|
re
.
S
)
tag
=
r"
%(otag)
s(#|=|!|>|\{)?(.+?)\1?
%(ctag)
s+"
tag
=
r"
%(otag)
s(#|=|
&|
!|>|\{)?(.+?)\1?
%(ctag)
s+"
self
.
tag_re
=
re
.
compile
(
tag
%
tags
)
def
render_sections
(
self
,
template
,
context
):
...
...
@@ -108,6 +108,7 @@ class Template(object):
return
''
@modifier
(
'{'
)
@modifier
(
'&'
)
def
render_unescaped
(
self
,
tag_name
=
None
,
context
=
None
):
"""Render a tag without escaping it."""
return
unicode
(
context
.
get
(
tag_name
,
''
))
...
...
tests/test_examples.py
View file @
a15519f4
...
...
@@ -38,6 +38,12 @@ class TestView(unittest.TestCase):
def
test_unescaped
(
self
):
self
.
assertEquals
(
Unescaped
()
.
render
(),
"<h1>Bear > Shark</h1>"
)
def
test_unescaped_sigil
(
self
):
view
=
Escaped
(
template
=
"<h1>{{& thing}}</h1>"
,
context
=
{
'thing'
:
'Bear > Giraffe'
})
self
.
assertEquals
(
view
.
render
(),
"<h1>Bear > Giraffe</h1>"
)
def
test_template_partial
(
self
):
self
.
assertEquals
(
TemplatePartial
()
.
render
(),
"""<h1>Welcome</h1>
Again, Welcome!"""
)
...
...
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