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
c49c0843
Commit
c49c0843
authored
Dec 10, 2011
by
Chris Jerdonek
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added code comments re: the spec's whitespace requirements.
parent
b00aaf4d
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
5 additions
and
2 deletions
+5
-2
pystache/template.py
+2
-0
tests/test_pystache.py
+3
-2
No files found.
pystache/template.py
View file @
c49c0843
...
...
@@ -72,6 +72,8 @@ class Template(object):
'ctag'
:
re
.
escape
(
self
.
ctag
)
}
# The section contents include white space to comply with the spec's
# requirement that sections not alter surrounding whitespace.
section
=
r"
%(otag)
s[\#|^]([^\}]*)
%(ctag)
s(.+?)
%(otag)
s/\1
%(ctag)
s"
self
.
section_re
=
re
.
compile
(
section
%
tags
,
re
.
M
|
re
.
S
)
...
...
tests/test_pystache.py
View file @
c49c0843
...
...
@@ -68,14 +68,15 @@ class TestPystache(unittest.TestCase):
context
=
{
'users'
:
[
{
'name'
:
'Chris'
},
{
'name'
:
'Tom'
},
{
'name'
:
'PJ'
}
]
}
ret
=
pystache
.
render
(
template
,
context
)
self
.
assertEquals
(
ret
,
"""<ul><li>Chris</li><li>Tom</li><li>PJ</li></ul>"""
)
def
test_implicit_iterator
(
self
):
template
=
"""<ul>{{#users}}<li>{{.}}</li>{{/users}}</ul>"""
context
=
{
'users'
:
[
'Chris'
,
'Tom'
,
'PJ'
]
}
ret
=
pystache
.
render
(
template
,
context
)
self
.
assertEquals
(
ret
,
"""<ul><li>Chris</li><li>Tom</li><li>PJ</li></ul>"""
)
def
test_spacing
(
self
):
# The spec says that sections should not alter surrounding whitespace.
def
test_surrounding_whitepace_not_altered
(
self
):
template
=
"first{{#spacing}} second {{/spacing}}third"
ret
=
pystache
.
render
(
template
,
{
"spacing"
:
True
})
self
.
assertEquals
(
ret
,
"first second third"
)
...
...
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