Commit 9d2da6ae by Chris Jerdonek

Renamed the loader argument of View.__init__() to "partials".

parent aaed5225
......@@ -25,23 +25,20 @@ class View(object):
_loader = None
_renderer = None
def __init__(self, template=None, context=None, loader=None, **kwargs):
def __init__(self, template=None, context=None, partials=None, **kwargs):
"""
Construct a View instance.
Arguments:
loader: the object (e.g. pystache.Loader or dictionary) responsible
for loading templates during the rendering process, for example
when loading partials. The object should have a get() method
that accepts a string and returns the corresponding template
as a string, preferably as a unicode string. The method should
return None if there is no template with that name.
partials: the object (e.g. pystache.Loader or dictionary)
responsible for loading partials during the rendering process.
The object should have a get() method that accepts a string and
returns the corresponding template as a string, preferably as a
unicode string. The method should return None if there is no
template with that name, or raise an exception.
"""
if loader is not None:
self._loader = loader
if template is not None:
self.template = template
......@@ -51,6 +48,8 @@ class View(object):
if kwargs:
_context.push(kwargs)
self._partials = partials
self.context = _context
def _get_renderer(self):
......@@ -60,7 +59,7 @@ class View(object):
# instantiation some of the attributes on which the Renderer
# depends. This lets users set the template_extension attribute,
# etc. after View.__init__() has already been called.
renderer = Renderer(partials=self._loader,
renderer = Renderer(partials=self._partials,
file_encoding=self.template_encoding,
search_dirs=self.template_path,
file_extension=self.template_extension)
......
......@@ -53,7 +53,7 @@ class ViewTestCase(unittest.TestCase):
"""
template = "{{>partial}}"
partials = {"partial": "Loaded from dictionary"}
view = Simple(template=template, loader=partials)
view = Simple(template=template, partials=partials)
actual = view.render()
self.assertEquals(actual, "Loaded from dictionary")
......
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