summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris Jerdonek <chris.jerdonek@gmail.com>2012-04-01 10:44:17 -0700
committerChris Jerdonek <chris.jerdonek@gmail.com>2012-04-01 10:44:17 -0700
commitd26bdf330adfecd073bd5e9b1f9780ba9d2d30d6 (patch)
tree3e8ce567f5404b376659b6790c8d5c4b7c78f3cf
parentaabb1c6bb2137ab8ad8be9702f2bf9e0d75b7343 (diff)
downloadpystache-d26bdf330adfecd073bd5e9b1f9780ba9d2d30d6.tar.gz
Minor tweaks to the SpecLoader class.
-rw-r--r--pystache/template_spec.py32
-rw-r--r--tests/test_template_spec.py2
2 files changed, 17 insertions, 17 deletions
diff --git a/pystache/template_spec.py b/pystache/template_spec.py
index d4f209c..b554261 100644
--- a/pystache/template_spec.py
+++ b/pystache/template_spec.py
@@ -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.
diff --git a/tests/test_template_spec.py b/tests/test_template_spec.py
index cbf61c4..13fd4e6 100644
--- a/tests/test_template_spec.py
+++ b/tests/test_template_spec.py
@@ -1,7 +1,7 @@
# coding: utf-8
"""
-Unit tests of view.py.
+Unit tests for template_spec.py.
"""