diff options
author | dbr <dbr.onix@gmail.com> | 2009-10-30 02:05:59 +0800 |
---|---|---|
committer | Chris Wanstrath <chris@ozmm.org> | 2009-10-31 01:20:56 +0800 |
commit | 40d09a12bf6fea33775b1e5cdc2af5438fd67cde (patch) | |
tree | 6405c7969d07a44270281c4131635649c04544af | |
parent | dbb50631d3daa99965cf726df46e06a7af256b9f (diff) | |
download | pystache-40d09a12bf6fea33775b1e5cdc2af5438fd67cde.tar.gz |
Pystash class with static method seems redundant,
change it to a single function. Also update the
tests
-rw-r--r-- | pystache/__init__.py | 6 | ||||
-rw-r--r-- | tests/test_pystache.py | 16 |
2 files changed, 10 insertions, 12 deletions
diff --git a/pystache/__init__.py b/pystache/__init__.py index c838c7c..f5caf36 100644 --- a/pystache/__init__.py +++ b/pystache/__init__.py @@ -1,6 +1,4 @@ from pystache.template import Template -class Pystache(object): - @staticmethod - def render(template, context={}): - return Template(template, context).render() +def render(template, context={}): + return Template(template, context).render() diff --git a/tests/test_pystache.py b/tests/test_pystache.py index 9623190..fbcf3ca 100644 --- a/tests/test_pystache.py +++ b/tests/test_pystache.py @@ -1,34 +1,34 @@ import unittest -from pystache import Pystache +import pystache class TestPystache(unittest.TestCase): def test_basic(self): - ret = Pystache.render("Hi {{thing}}!", { 'thing': 'world' }) + ret = pystache.render("Hi {{thing}}!", { 'thing': 'world' }) self.assertEquals(ret, "Hi world!") def test_less_basic(self): template = "It's a nice day for {{beverage}}, right {{person}}?" - ret = Pystache.render(template, { 'beverage': 'soda', 'person': 'Bob' }) + ret = pystache.render(template, { 'beverage': 'soda', 'person': 'Bob' }) self.assertEquals(ret, "It's a nice day for soda, right Bob?") def test_even_less_basic(self): template = "I think {{name}} wants a {{thing}}, right {{name}}?" - ret = Pystache.render(template, { 'name': 'Jon', 'thing': 'racecar' }) + ret = pystache.render(template, { 'name': 'Jon', 'thing': 'racecar' }) self.assertEquals(ret, "I think Jon wants a racecar, right Jon?") def test_comments(self): template = "What {{! the }} what?" - ret = Pystache.render(template) + ret = pystache.render(template) self.assertEquals(ret, "What what?") def test_false_sections_are_hidden(self): template = "Ready {{#set}}set {{/set}}go!" - ret = Pystache.render(template, { 'set': False }) + ret = pystache.render(template, { 'set': False }) self.assertEquals(ret, "Ready go!") def test_true_sections_are_shown(self): template = "Ready {{#set}}set{{/set}} go!" - ret = Pystache.render(template, { 'set': True }) + ret = pystache.render(template, { 'set': True }) self.assertEquals(ret, "Ready set go!") def test_sections(self): @@ -41,7 +41,7 @@ class TestPystache(unittest.TestCase): """ context = { 'users': [ {'name': 'Chris'}, {'name': 'Tom'}, {'name': 'PJ'} ] } - ret = Pystache.render(template, context) + ret = pystache.render(template, context) self.assertEquals(ret, """ <ul> <li>Chris</li><li>Tom</li><li>PJ</li> |