Commit d595856b by Chris Jerdonek

READM view example is now more real.

parent f143e1ed
...@@ -41,21 +41,24 @@ Use It ...@@ -41,21 +41,24 @@ Use It
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 view class (in `examples/readme.py`)::
>>> class Simple(object): class SayHello(object):
... def thing(self): def to(self):
... return "pizza" return "World"
Then your template, simple.mustache:: >>> from examples.readme import SayHello
>>> hello = SayHello()
Hi {{thing}}! Then your template, `say_hello.mustache`::
Hello, {{to}}!
Pull it together:: Pull it together::
>>> renderer = pystache.Renderer(search_dirs='examples') >>> renderer = pystache.Renderer()
>>> renderer.render(Simple()) >>> renderer.render(hello)
u'Hi pizza!' u'Hello, World!'
Test It Test It
......
class SayHello(object):
def to(self):
return "World"
Hello, {{to}}!
\ No newline at end of file
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