This repository has been archived on 2019-12-12. You can view files and clone it, but cannot push or open issues/pull-requests.
tildetown-scripts/tildetown/mustache.py

23 lines
453 B
Python
Raw Normal View History

2015-10-05 23:41:42 +00:00
from json import loads
from sys import argv,stdin
from pystache import render
2017-04-21 05:00:25 +00:00
def slurp(file_path):
contents = None
try:
with open(file_path, 'r', encoding="utf-8") as f:
contents = f.read()
except FileNotFoundError:
pass
except UnicodeDecodeError:
pass
return contents
2015-10-05 23:41:42 +00:00
if __name__ == '__main__':
template = slurp(argv[1])
data = loads(stdin.read())
print(render(template, data))