Commit 2976f997 by Chris Jerdonek

Stubbed out view.Locator class.

parent 32adefb9
...@@ -103,3 +103,21 @@ class View(object): ...@@ -103,3 +103,21 @@ class View(object):
def __str__(self): def __str__(self):
return self.render() return self.render()
class Locator(object):
"""
A class for finding the template associated to a View instance.
"""
def __init__(self):
pass
def get_template(self, view):
if view.template is not None:
return view.template
# TODO: locate template
return None
...@@ -6,6 +6,7 @@ from examples.complex_view import ComplexView ...@@ -6,6 +6,7 @@ from examples.complex_view import ComplexView
from examples.lambdas import Lambdas from examples.lambdas import Lambdas
from examples.inverted import Inverted, InvertedLists from examples.inverted import Inverted, InvertedLists
from pystache.view import View from pystache.view import View
from pystache.view import Locator
class Thing(object): class Thing(object):
...@@ -168,5 +169,16 @@ class ViewTestCase(unittest.TestCase): ...@@ -168,5 +169,16 @@ class ViewTestCase(unittest.TestCase):
view = InvertedLists() view = InvertedLists()
self.assertEquals(view.render(), """one, two, three, empty list""") self.assertEquals(view.render(), """one, two, three, empty list""")
if __name__ == '__main__':
unittest.main() class LocatorTests(unittest.TestCase):
def _make_locator(self):
locator = Locator()
return locator
def test_get_template(self):
locator = self._make_locator()
view = View()
view.template = 'foo'
self.assertEquals(locator.get_template(view), 'foo')
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