Skip to content

Instantly share code, notes, and snippets.

@bahorn
Created May 2, 2018 18:56
Show Gist options
  • Save bahorn/eed8d9dd6c549f53b5fc16501210a366 to your computer and use it in GitHub Desktop.
Save bahorn/eed8d9dd6c549f53b5fc16501210a366 to your computer and use it in GitHub Desktop.
Jinja2 Template preview
import sys
from jinja2 import Template
def renderTemplate(template, context):
t = Template(template)
return t.render(context)
if __name__ == "__main__":
context = {}
template = open(sys.argv[1],'r').read()
for arg in sys.argv[2::]:
name, value = arg.split('=')
context[name] = value
print(renderTemplate(template, context))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment