summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris Wanstrath <chris@ozmm.org>2009-10-30 13:17:51 -0700
committerChris Wanstrath <chris@ozmm.org>2009-10-30 13:17:51 -0700
commita15d877250b27e7388138a1bf11fcee369dd5f2b (patch)
treeeccc1f473ec11f1fe85856aef09d7a38e127cf4b
parentb5d3089259324b6d0cddb4f92561e6600d7c7808 (diff)
parent729b2e2cd2652450244f5ad129c3d258f8aa7319 (diff)
downloadpystache-a15d877250b27e7388138a1bf11fcee369dd5f2b.tar.gz
Merge remote branch 'ericflo/master'
-rw-r--r--pystache/__init__.py7
-rw-r--r--pystache/template.py4
-rw-r--r--pystache/view.py8
3 files changed, 8 insertions, 11 deletions
diff --git a/pystache/__init__.py b/pystache/__init__.py
index 913dc61..bb832b8 100644
--- a/pystache/__init__.py
+++ b/pystache/__init__.py
@@ -1,8 +1,7 @@
from pystache.template import Template
from pystache.view import View
-def render(template, context={}, **kwargs):
- context = context.copy()
- for key in kwargs:
- context[key] = kwargs[key]
+def render(template, context=None, **kwargs):
+ context = context and context.copy() or {}
+ context.update(kwargs)
return Template(template, context).render()
diff --git a/pystache/template.py b/pystache/template.py
index e8c04a4..d0d2c65 100644
--- a/pystache/template.py
+++ b/pystache/template.py
@@ -9,9 +9,9 @@ class Template(object):
'!': 'comment'
}
- def __init__(self, template, context={}):
+ def __init__(self, template, context=None):
self.template = template
- self.context = context
+ self.context = context or {}
def render(self, template=None, context=None):
"""Turns a Mustache template into something wonderful."""
diff --git a/pystache/view.py b/pystache/view.py
index bae1773..2e5ee41 100644
--- a/pystache/view.py
+++ b/pystache/view.py
@@ -15,12 +15,10 @@ class View(object):
# Contents of the template.
template = None
- def __init__(self, template=None, context={}, **kwargs):
+ def __init__(self, template=None, context=None, **kwargs):
self.template = template
- self.context = context
-
- for key in kwargs:
- self.context[key] = kwargs[key]
+ self.context = context or {}
+ self.context.update(kwargs)
def load_template(self):
if self.template: