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
dc732360
Commit
dc732360
authored
Jan 24, 2012
by
Chris Jerdonek
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added support for view.template_directory.
parent
8782cc27
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
18 additions
and
1 deletions
+18
-1
pystache/view.py
+8
-1
tests/test_view.py
+10
-0
No files found.
pystache/view.py
View file @
dc732360
...
@@ -31,6 +31,9 @@ class View(object):
...
@@ -31,6 +31,9 @@ class View(object):
template_path: the path to the template file, relative to the
template_path: the path to the template file, relative to the
directory containing the module defining the class.
directory containing the module defining the class.
template_dir: the directory containing the template file, relative
to the directory containing the module defining the class.
template_extension: the template file extension. Defaults to "mustache".
template_extension: the template file extension. Defaults to "mustache".
Pass False for no extension (i.e. extensionless template files).
Pass False for no extension (i.e. extensionless template files).
...
@@ -39,6 +42,7 @@ class View(object):
...
@@ -39,6 +42,7 @@ class View(object):
template
=
None
template
=
None
template_path
=
None
template_path
=
None
template_directory
=
None
template_name
=
None
template_name
=
None
template_extension
=
None
template_extension
=
None
...
@@ -157,6 +161,9 @@ class Locator(object):
...
@@ -157,6 +161,9 @@ class Locator(object):
"""
"""
if
view
.
template_path
is
not
None
:
if
view
.
template_path
is
not
None
:
return
os
.
path
.
split
(
view
.
template_path
)
return
os
.
path
.
split
(
view
.
template_path
)
template_dir
=
view
.
template_directory
# Otherwise, we don't know the directory.
# Otherwise, we don't know the directory.
template_name
=
(
view
.
template_name
if
view
.
template_name
is
not
None
else
template_name
=
(
view
.
template_name
if
view
.
template_name
is
not
None
else
...
@@ -164,7 +171,7 @@ class Locator(object):
...
@@ -164,7 +171,7 @@ class Locator(object):
file_name
=
self
.
template_locator
.
make_file_name
(
template_name
,
view
.
template_extension
)
file_name
=
self
.
template_locator
.
make_file_name
(
template_name
,
view
.
template_extension
)
return
(
None
,
file_name
)
return
(
template_dir
,
file_name
)
def
get_template_path
(
self
,
view
):
def
get_template_path
(
self
,
view
):
"""
"""
...
...
tests/test_view.py
View file @
dc732360
...
@@ -226,6 +226,16 @@ class LocatorTests(unittest.TestCase, AssertIsMixin):
...
@@ -226,6 +226,16 @@ class LocatorTests(unittest.TestCase, AssertIsMixin):
view
.
template_path
=
'foo/bar/template.txt'
view
.
template_path
=
'foo/bar/template.txt'
self
.
_assert_template_location
(
view
,
(
'foo/bar'
,
'template.txt'
))
self
.
_assert_template_location
(
view
,
(
'foo/bar'
,
'template.txt'
))
def
test_get_relative_template_location__template_directory
(
self
):
"""
Test get_relative_template_location(): template_directory attribute.
"""
view
=
SampleView
()
view
.
template_directory
=
'foo'
self
.
_assert_template_location
(
view
,
(
'foo'
,
'sample_view.mustache'
))
def
test_get_relative_template_location__template_name
(
self
):
def
test_get_relative_template_location__template_name
(
self
):
"""
"""
Test get_relative_template_location(): template_name attribute.
Test get_relative_template_location(): template_name attribute.
...
...
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