Last active
April 28, 2017 07:56
-
-
Save sayanriju/77363fd935099b8b9dbf99bad9ebbd87 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
import sys | |
import json | |
import jinja2 | |
templateLoader = jinja2.FileSystemLoader( searchpath="./" ) | |
templateEnv = jinja2.Environment( loader=templateLoader ) | |
template_file = sys.argv[1] | |
data_file = sys.argv[2] ## .json file | |
output_file = template_file+'.html' | |
template = templateEnv.get_template( template_file ) | |
with open( data_file, 'r' ) as json_data: | |
data = json.load( json_data ) | |
rendered = template.render( data ) | |
with open( output_file, 'w' ) as op: | |
op.write( rendered ) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment