]> Devi Nivas Git - chevron.git/commitdiff
Added complete unpacking ability to render
authornoah morrison <noah@morrison.ph>
Wed, 12 Nov 2014 15:11:43 +0000 (10:11 -0500)
committernoah morrison <noah@morrison.ph>
Wed, 12 Nov 2014 15:11:43 +0000 (10:11 -0500)
All of renders args are now KWargs

entei.py

index 8d1e9f4c0de39d5b2efdf33a1eedc4a6b9b373e4..0958f3ee7427025fc85e5c24b2c7dad313283e98 100755 (executable)
--- a/entei.py
+++ b/entei.py
@@ -146,7 +146,7 @@ def tokenize(template):
         raise UnclosedSection()
 
 
-def render(template, data, partials_path='.', partials_ext='mustache',
+def render(template='', data={}, partials_path='.', partials_ext='mustache',
            partials_dict={}, padding=0):
     """Render a mustache template.
 
@@ -298,8 +298,10 @@ def render(template, data, partials_path='.', partials_ext='mustache',
     return output
 
 if __name__ == '__main__':
-    data = argv[1]
-    template = argv[2]
+    args = {
+        'template': open(argv[2], 'r'),
+        'data': json.load(open(argv[1], 'r')),
+    }
 
-    output = render(open(template, 'r'), json.load(open(data, 'r')))
+    output = render(**args)
     print(output)