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
9d082532
Commit
9d082532
authored
Mar 18, 2012
by
Chris Jerdonek
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added CustomizedTemplate class.
parent
9148826d
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
16 additions
and
11 deletions
+16
-11
examples/comments.mustache
+2
-1
examples/comments.py
+2
-2
pystache/init.py
+2
-1
pystache/view.py
+5
-2
tests/test_examples.py
+5
-4
tests/test_renderer.py
+0
-1
No files found.
examples/comments.mustache
View file @
9d082532
<h1>
{{
title
}}
{{! just something interesting... #or not... }}
</h1>
<h1>
{{
title
}}
{{! just something interesting... #or not... }}
</h1>
\ No newline at end of file
examples/comments.py
View file @
9d082532
import
pystach
e
from
pystache
import
CustomizedTemplat
e
class
Comments
(
pystache
.
View
):
class
Comments
(
CustomizedTemplate
):
template_path
=
'examples'
def
title
(
self
):
...
...
pystache/init.py
View file @
9d082532
...
...
@@ -7,9 +7,10 @@ This module contains the initialization logic called by __init__.py.
from
.renderer
import
Renderer
from
.view
import
View
from
.view
import
CustomizedTemplate
__all__
=
[
'render'
,
'Renderer'
,
'View'
]
__all__
=
[
'render'
,
'Renderer'
,
'View'
,
'CustomizedTemplate'
]
def
render
(
template
,
context
=
None
,
**
kwargs
):
...
...
pystache/view.py
View file @
9d082532
...
...
@@ -13,8 +13,7 @@ from .reader import Reader
from
.renderer
import
Renderer
# TODO: rename this class to something else (e.g. ITemplateInfo)
class
View
(
object
):
class
CustomizedTemplate
(
object
):
"""
Subclass this class only if template customizations are needed.
...
...
@@ -48,6 +47,10 @@ class View(object):
template_encoding
=
None
# TODO: remove this class.
class
View
(
CustomizedTemplate
):
_renderer
=
None
locator
=
TemplateLocator
()
...
...
tests/test_examples.py
View file @
9d082532
# encoding: utf-8
import
unittest
import
pystache
from
examples.comments
import
Comments
from
examples.double_section
import
DoubleSection
...
...
@@ -12,14 +11,16 @@ 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
tests.common
import
assert_strings
class
TestView
(
unittest
.
TestCase
):
def
test_comments
(
self
):
self
.
assertEquals
(
Comments
()
.
render
(),
"""<h1>A Comedy of Errors</h1>
"""
)
renderer
=
Renderer
()
expected
=
renderer
.
render
(
Comments
())
self
.
assertEquals
(
expected
,
"<h1>A Comedy of Errors</h1>"
)
def
test_double_section
(
self
):
self
.
assertEquals
(
DoubleSection
()
.
render
(),
"""* first
\n
* second
\n
* third"""
)
...
...
tests/test_renderer.py
View file @
9d082532
...
...
@@ -11,7 +11,6 @@ import sys
import
unittest
from
examples.simple
import
Simple
from
pystache
import
renderer
from
pystache.renderer
import
Renderer
from
pystache.locator
import
Locator
...
...
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