Commit 921cd282 by Chris Jerdonek

Got doctests in README.rst working.

parent 7b7138b7
...@@ -37,16 +37,17 @@ Use It ...@@ -37,16 +37,17 @@ Use It
>>> import pystache >>> import pystache
>>> pystache.render('Hi {{person}}!', {'person': 'Mom'}) >>> pystache.render('Hi {{person}}!', {'person': 'Mom'})
'Hi Mom!' u'Hi Mom!'
You can also create dedicated view classes to hold your view logic. You can also create dedicated view classes to hold your view logic.
Here's your simple.py:: Here's your simple.py::
import pystache >>> import pystache
class Simple(pystache.View): >>> class Simple(pystache.View):
def thing(self): ... template_path = 'examples'
return "pizza" ... def thing(self):
... return "pizza"
Then your template, simple.mustache:: Then your template, simple.mustache::
...@@ -55,7 +56,7 @@ Then your template, simple.mustache:: ...@@ -55,7 +56,7 @@ Then your template, simple.mustache::
Pull it together:: Pull it together::
>>> Simple().render() >>> Simple().render()
'Hi pizza!' u'Hi pizza!'
Test It Test It
...@@ -65,7 +66,7 @@ nose_ works great! :: ...@@ -65,7 +66,7 @@ nose_ works great! ::
pip install nose pip install nose
cd pystache cd pystache
nosetests --with-doctest nosetests --with-doctest --doctest-extension=rst
To include tests from the mustache spec_ in your test runs: :: To include tests from the mustache spec_ in your test runs: ::
......
...@@ -310,7 +310,7 @@ class Renderer(object): ...@@ -310,7 +310,7 @@ class Renderer(object):
def render(self, template, *context, **kwargs): def render(self, template, *context, **kwargs):
""" """
Render the given template (or templated object) using the given context. Render the given template (or template object) using the given context.
Returns the rendering as a unicode string. Returns the rendering as a unicode string.
...@@ -321,11 +321,11 @@ class Renderer(object): ...@@ -321,11 +321,11 @@ class Renderer(object):
Arguments: Arguments:
template: a template string of type unicode or str, or an object template: a template string of type unicode or str, or an object
instance. If the argument is an object, for the template string instance. If the argument is an object, the function first looks
the function attempts to find a template associated to the for the template associated to the object by calling this class's
object by calling the get_associated_template() method. The get_associated_template() method. The rendering process also
argument in this case is also used as the first element of the uses the passed object as the first element of the context stack
context stack when rendering the associated template. when rendering.
*context: zero or more dictionaries, Context instances, or objects *context: zero or more dictionaries, Context instances, or objects
with which to populate the initial context stack. None with which to populate the initial context stack. None
......
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