'Creates the Jinja2 environment based on :attr:`jinja_options`
and :meth:`select_jinja_autoescape`.  Since 0.7 this also adds
the Jinja2 globals and filters after initialization.  Override
this function to customize the behavior.
.. versionadded:: 0.5
.. versionchanged:: 0.11
``Environment.auto_reload`` set in accordance with
``TEMPLATES_AUTO_RELOAD`` configuration option.'

def create_jinja_environment(self):

    options = dict(self.jinja_options)
    if ('autoescape' not in options):
        options['autoescape'] = self.select_jinja_autoescape
    if ('auto_reload' not in options):
        options['auto_reload'] = self.templates_auto_reload
    rv = self.jinja_environment(self, **options)
    rv.globals.update(url_for=url_for, get_flashed_messages=get_flashed_messages, config=self.config, request=request, session=session, g=g)
    rv.filters['tojson'] = json.tojson_filter
    return rv
