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
743ed3c2
Commit
743ed3c2
authored
Mar 19, 2012
by
Chris Jerdonek
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
The "ComplexView" tests no longer depend on pystache.View.
parent
a6064355
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
26 additions
and
13 deletions
+26
-13
examples/complex_view.mustache
+7
-2
examples/complex_view.py
+2
-4
tests/test_examples.py
+1
-1
tests/test_simple.py
+6
-4
tests/test_view.py
+10
-2
No files found.
examples/complex_view.mustache
View file @
743ed3c2
<h1>
{{
header
}}
</h1>
{{#
list
}}
<ul>
{{#
item
}}{{#
current
}}
<li><strong>
{{
name
}}
</strong></li>
{{/
current
}}{{#
link
}}
<li><a
href=
"
{{
url
}}
"
>
{{
name
}}
</a></li>
{{/
link
}}{{/
item
}}
</ul>
{{/
list
}}{{#
empty
}}
<p>
The list is empty.
</p>
{{/
empty
}}
\ No newline at end of file
<h1>
{{
header
}}
</h1>
{{#
list
}}
<ul>
{{#
item
}}{{#
current
}}
<li><strong>
{{
name
}}
</strong></li>
{{/
current
}}{{#
link
}}
<li><a
href=
"
{{
url
}}
"
>
{{
name
}}
</a></li>
{{/
link
}}{{/
item
}}
</ul>
{{/
list
}}{{#
empty
}}
<p>
The list is empty.
</p>
{{/
empty
}}
\ No newline at end of file
examples/complex_view.py
View file @
743ed3c2
import
pystache
class
ComplexView
(
pystache
.
View
):
class
ComplexView
(
object
):
template_path
=
'examples'
def
header
(
self
):
...
...
@@ -18,6 +16,6 @@ class ComplexView(pystache.View):
def
empty
(
self
):
return
len
(
self
.
item
())
==
0
def
empty_list
(
self
):
return
[];
tests/test_examples.py
View file @
743ed3c2
...
...
@@ -11,7 +11,7 @@ from examples.delimiters import Delimiters
from
examples.unicode_output
import
UnicodeOutput
from
examples.unicode_input
import
UnicodeInput
from
examples.nested_context
import
NestedContext
from
pystache
.renderer
import
Renderer
from
pystache
import
Renderer
from
tests.common
import
assert_strings
...
...
tests/test_simple.py
View file @
743ed3c2
...
...
@@ -19,12 +19,14 @@ class TestSimple(unittest.TestCase):
self
.
assertEquals
(
view
.
render
(),
"one and foo and two"
)
def
test_looping_and_negation_context
(
self
):
view
=
ComplexView
()
view
.
template
=
'{{#item}}{{header}}: {{name}} {{/item}}{{^item}} Shouldnt see me{{/item}}'
self
.
assertEquals
(
view
.
render
(),
"Colors: red Colors: green Colors: blue "
)
template
=
'{{#item}}{{header}}: {{name}} {{/item}}{{^item}} Shouldnt see me{{/item}}'
context
=
ComplexView
()
renderer
=
Renderer
()
expected
=
renderer
.
render
(
template
,
context
)
self
.
assertEquals
(
expected
,
"Colors: red Colors: green Colors: blue "
)
def
test_empty_context
(
self
):
view
=
ComplexView
()
template
=
'{{#empty_list}}Shouldnt see me {{/empty_list}}{{^empty_list}}Should see me{{/empty_list}}'
self
.
assertEquals
(
pystache
.
Renderer
()
.
render
(
template
),
"Should see me"
)
...
...
tests/test_view.py
View file @
743ed3c2
...
...
@@ -12,6 +12,7 @@ from examples.simple import Simple
from
examples.complex_view
import
ComplexView
from
examples.lambdas
import
Lambdas
from
examples.inverted
import
Inverted
,
InvertedLists
from
pystache
import
Renderer
from
pystache.reader
import
Reader
from
pystache.view
import
View
from
pystache.view
import
Locator
as
ViewLocator
...
...
@@ -78,8 +79,15 @@ class ViewTestCase(unittest.TestCase):
self
.
assertEquals
(
view
.
render
(),
"Hi Chris!"
)
def
test_complex
(
self
):
self
.
assertEquals
(
ComplexView
()
.
render
(),
"""<h1>Colors</h1><ul><li><strong>red</strong></li><li><a href="#Green">green</a></li><li><a href="#Blue">blue</a></li></ul>"""
)
renderer
=
Renderer
()
expected
=
renderer
.
render
(
ComplexView
())
self
.
assertEquals
(
expected
,
"""
\
<h1>Colors</h1>
<ul>
<li><strong>red</strong></li>
<li><a href="#Green">green</a></li>
<li><a href="#Blue">blue</a></li>
</ul>"""
)
def
test_higher_order_replace
(
self
):
view
=
Lambdas
()
...
...
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