02_basic_loading_of_a_template 

Send to Kindle
home » snippets » python » jinja2 » example » 02_basic_loading_of_a_template



Basic loading of a template.

# -*- coding: UTF-8 -*-

# This will create a template environment with the
# default settings and a loader that looks up the
# templates in the templates folder inside the
# yourapplication python package.

import jinja2
env = jinja2.Environment(
    loader=jinja2.PackageLoader('yourapplication', 'templates'))

# Load template from an environment.
template = env.get_template('mytemplate.html')

# Render a template.
print template.render(the='variables', go='here')