Skip to content

Instantly share code, notes, and snippets.

@sayanriju
Last active April 28, 2017 07:56
Show Gist options
  • Save sayanriju/77363fd935099b8b9dbf99bad9ebbd87 to your computer and use it in GitHub Desktop.
Save sayanriju/77363fd935099b8b9dbf99bad9ebbd87 to your computer and use it in GitHub Desktop.
#!/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