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
d26bdf33
Commit
d26bdf33
authored
Apr 01, 2012
by
Chris Jerdonek
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Minor tweaks to the SpecLoader class.
parent
aabb1c6b
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
17 additions
and
17 deletions
+17
-17
pystache/template_spec.py
+16
-16
tests/test_template_spec.py
+1
-1
No files found.
pystache/template_spec.py
View file @
d26bdf33
...
...
@@ -141,27 +141,28 @@ class SpecLoader(object):
self
.
loader
=
loader
self
.
search_dirs
=
search_dirs
def
_find_relative
(
self
,
view
):
def
_find_relative
(
self
,
spec
):
"""
Return the
relative template path as a
(dir, file_name) pair.
Return the
path to the template as a relative
(dir, file_name) pair.
"""
if
view
.
template_rel_path
is
not
None
:
return
os
.
path
.
split
(
view
.
template_rel_path
)
template_dir
=
view
.
template_rel_directory
The directory returned is relative to the directory containing the
class definition of the given object. The method returns None for
this directory if the directory is unknown without first searching
the search directories.
# Otherwise, we don't know the directory.
"""
if
spec
.
template_rel_path
is
not
None
:
return
os
.
path
.
split
(
spec
.
template_rel_path
)
#
TODO: share code with the loader attribute here
.
locator
=
Locator
(
extension
=
self
.
loader
.
extension
)
#
Otherwise, determine the file name separately
.
locator
=
self
.
loader
.
_make_locator
(
)
template_name
=
(
view
.
template_name
if
view
.
template_name
is
not
None
else
locator
.
make_template_name
(
view
))
template_name
=
(
spec
.
template_name
if
spec
.
template_name
is
not
None
else
locator
.
make_template_name
(
spec
))
file_name
=
locator
.
make_file_name
(
template_name
,
view
.
template_extension
)
file_name
=
locator
.
make_file_name
(
template_name
,
spec
.
template_extension
)
return
(
template_dir
,
file_name
)
return
(
spec
.
template_rel_directory
,
file_name
)
def
_find
(
self
,
spec
):
"""
...
...
@@ -170,8 +171,7 @@ class SpecLoader(object):
"""
dir_path
,
file_name
=
self
.
_find_relative
(
spec
)
# TODO: share code with the loader attribute here.
locator
=
Locator
(
extension
=
self
.
loader
.
extension
)
locator
=
self
.
loader
.
_make_locator
()
if
dir_path
is
None
:
# Then we need to search for the path.
...
...
tests/test_template_spec.py
View file @
d26bdf33
# coding: utf-8
"""
Unit tests
of view
.py.
Unit tests
for template_spec
.py.
"""
...
...
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