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
a27c2915
Commit
a27c2915
authored
Mar 23, 2012
by
Chris Jerdonek
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Made search_dirs an optional argument to Loader.__init__().
parent
d54cc252
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
28 additions
and
8 deletions
+28
-8
pystache/custom_template.py
+8
-4
tests/test_custom_template.py
+20
-4
No files found.
pystache/custom_template.py
View file @
a27c2915
...
...
@@ -13,6 +13,7 @@ from .reader import Reader
from
.renderer
import
Renderer
# TODO: rename this to Template?
class
CustomizedTemplate
(
object
):
"""
...
...
@@ -126,16 +127,19 @@ class Loader(object):
"""
def
__init__
(
self
,
search_dirs
,
locator
=
None
,
reader
=
None
):
def
__init__
(
self
,
search_dirs
=
None
,
locator
=
None
,
reader
=
None
):
if
locator
is
None
:
locator
=
TemplateLocator
()
if
reader
is
None
:
reader
=
Reader
()
if
locator
is
None
:
locator
=
TemplateLocator
()
if
search_dirs
is
None
:
search_dirs
=
[]
self
.
locator
=
locator
self
.
reader
=
reader
self
.
search_dirs
=
search_dirs
self
.
locator
=
locator
# TODO: make this private.
def
get_relative_template_location
(
self
,
view
):
...
...
tests/test_custom_template.py
View file @
a27c2915
...
...
@@ -13,6 +13,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
CustomizedTemplate
as
Template
from
pystache
import
Renderer
from
pystache
import
View
from
pystache.custom_template
import
Loader
...
...
@@ -142,16 +143,19 @@ class LoaderTests(unittest.TestCase, AssertIsMixin):
"""
def
test_init__defaults
(
self
):
loader
=
Loader
([])
loader
=
Loader
()
# Check the locator attribute.
locator
=
loader
.
locator
self
.
assertEquals
(
locator
.
template_extension
,
'mustache'
)
# Check the reader attribute.
reader
=
loader
.
reader
self
.
assertEquals
(
reader
.
decode_errors
,
'strict'
)
self
.
assertEquals
(
reader
.
encoding
,
sys
.
getdefaultencoding
())
# Check the locator attribute.
locator
=
loader
.
locator
self
.
assertEquals
(
locator
.
template_extension
,
'mustache'
)
# Check search_dirs.
self
.
assertEquals
(
loader
.
search_dirs
,
[])
def
test_init__search_dirs
(
self
):
search_dirs
=
[
'a'
,
'b'
]
...
...
@@ -171,6 +175,18 @@ class LoaderTests(unittest.TestCase, AssertIsMixin):
self
.
assertIs
(
loader
.
locator
,
locator
)
def
test_load__template__basic
(
self
):
"""
Test the template attribute.
"""
template
=
Template
()
template
.
template
=
"abc"
loader
=
Loader
()
self
.
assertEquals
(
loader
.
load
(
template
),
"wxy"
)
# TODO: migrate these tests into the LoaderTests class.
# TODO: rename the get_template() tests to test load().
...
...
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