Created
March 5, 2021 22:04
-
-
Save selivan/bd0df550920fc396f24f4e10185fb063 to your computer and use it in GitHub Desktop.
Python3 script to render jinja2 template. Requirements: pip install jinja2
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 python3 | |
from jinja2 import Template | |
import sys | |
if len(sys.argv) < 3: | |
print(f'Usage: sys.argv[0] template_file output_file') | |
template_file = sys.argv[1] | |
out_file = sys.argv[2] | |
raw_template = open(template_file, 'r').read() | |
tm = Template(raw_template) | |
rendered_template = tm.render() | |
open(out_file, 'w').write(rendered_template) | |
print(f'Template: {template_file}\nRendered: {out_file}') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment