Commit afb12bbe by Chris Jerdonek

Renamed custom_template.Locator to custom_template.Loader.

parent 8c2e922c
...@@ -16,6 +16,8 @@ from .renderer import Renderer ...@@ -16,6 +16,8 @@ from .renderer import Renderer
class CustomizedTemplate(object): class CustomizedTemplate(object):
""" """
A mixin for specifying custom template information.
Subclass this class only if template customizations are needed. Subclass this class only if template customizations are needed.
The following attributes allow one to customize/override template The following attributes allow one to customize/override template
...@@ -117,10 +119,10 @@ class View(CustomizedTemplate): ...@@ -117,10 +119,10 @@ class View(CustomizedTemplate):
return renderer.render(template, self.context) return renderer.render(template, self.context)
class Locator(object): class Loader(object):
""" """
A class for finding the template associated to a View instance. Supports loading the template of a CustomizedTemplate instance.
""" """
......
...@@ -15,7 +15,7 @@ from examples.inverted import Inverted, InvertedLists ...@@ -15,7 +15,7 @@ from examples.inverted import Inverted, InvertedLists
from pystache import Renderer from pystache import Renderer
from pystache import View from pystache import View
from pystache.reader import Reader from pystache.reader import Reader
from pystache.custom_template import Locator as ViewLocator from pystache.custom_template import Loader
from .common import AssertIsMixin from .common import AssertIsMixin
from .common import DATA_DIR from .common import DATA_DIR
from .data.views import SampleView from .data.views import SampleView
...@@ -132,16 +132,17 @@ class ViewTestCase(unittest.TestCase): ...@@ -132,16 +132,17 @@ class ViewTestCase(unittest.TestCase):
self.assertEquals(view.render(), """one, two, three, empty list""") self.assertEquals(view.render(), """one, two, three, empty list""")
class LocatorTests(unittest.TestCase, AssertIsMixin): class LoaderTests(unittest.TestCase, AssertIsMixin):
# TODO: rename this method to _make_loader().
def _make_locator(self): def _make_locator(self):
locator = ViewLocator(search_dirs=[DATA_DIR]) locator = Loader(search_dirs=[DATA_DIR])
return locator return locator
# TODO: fully test constructor. # TODO: fully test constructor.
def test_init__reader(self): def test_init__reader(self):
reader = "reader" # in practice, this is a reader instance. reader = "reader" # in practice, this is a reader instance.
locator = ViewLocator(search_dirs=None, template_locator=None, reader=reader) locator = Loader(search_dirs=None, template_locator=None, reader=reader)
self.assertIs(locator.reader, reader) self.assertIs(locator.reader, reader)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment