Created
August 23, 2013 20:40
-
-
Save fmariluis/6323783 to your computer and use it in GitHub Desktop.
Basic Jinja2 workflow
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
import jinja2 | |
templateLoader = jinja2.FileSystemLoader(searchpath="templates") | |
templateEnv = jinja2.Environment(loader=templateLoader) | |
templateEnv.trim_blocks = True | |
template = templateEnv.get_template(TEMPLATE_FILE) | |
templateVars = { | |
"nombre_tabla": "ubicaciones", | |
"lista_campos": campos, | |
"inserts": inserts | |
} | |
output = template.render(templateVars) | |
with open((os.path.join(DIR_OUTPUT_SQL, 'datos.sql')), 'w') as f: | |
f.write(output.encode('utf-8')) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment