add mustache helper

master
nathaniel smith 2015-10-05 16:41:42 -07:00
parent b55df2c198
commit 0b90e84577
3 changed files with 14 additions and 18 deletions

View File

@ -1,16 +0,0 @@
(import [json [loads]])
(import [sys [argv stdin]])
(import [pystache [render]])
(defn slurp [filename]
(try
(.read (apply open [filename "r"] {"encoding" "utf-8"}))
(catch [e Exception]
"")))
(if (= __name__ "__main__")
(let [[template (-> (get argv 1)
slurp)]
[data (-> (.read stdin)
loads)]]
(print (render template data))))

View File

@ -4,7 +4,7 @@ from setuptools import setup
setup(
name='tildetown',
version='0.0.1',
version='0.0.2',
description='python stuf for tilde.town',
url='https://github.com/tildetown/tildetown-scripts',
author='vilmibm shaksfrpease',
@ -18,5 +18,5 @@ setup(
],
keywords='community',
packages=['tildetown'],
install_requires = ['pyhocon==0.3.10', 'sh==1.11', 'Flask==0.10.1', 'requests==2.7.0'],
install_requires = ['pyhocon==0.3.10', 'sh==1.11', 'Flask==0.10.1', 'requests==2.7.0', 'pystache==0.5.4'],
)

View File

@ -0,0 +1,12 @@
from json import loads
from sys import argv,stdin
from pystache import render
from tildetown.util import slurp
if __name__ == '__main__':
template = slurp(argv[1])
data = loads(stdin.read())
print(render(template, data))