Skip to content
Myr

added create_jinja_loader

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by Armin Ronacher · committed by Armin Ronacher · parent b49de85 · Browse files · 3 files+23 added−1 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

3 files+23 added−1 removed

  • tests:+13 added−0 removed
  • other:+10 added−1 removed

3 files+23 added−1 removed

modified:flask/app.py+9 added-1 removed
350 unmodified lines
351 """352 options = dict(self.jinja_options)353 if 'autoescape' not in options:354 options['autoescape'] = self.select_jinja_autoescape355 return Environment(loader=_DispatchingJinjaLoader(self), **options)355 return Environment(loader=self.create_jinja_loader(), **options)356357 def create_jinja_loader(self):358 """Creates the loader for the Jinja2 environment. Can be used to359 override just the loader and keeping the rest unchanged.360361 .. versionadded:: 0.7362 """363 return _DispatchingJinjaLoader(self)364365 def init_jinja_globals(self):366 """Called directly after the environment was created to inject367 some defaults (like `url_for`, `get_flashed_messages` and the368 `tojson` filter.
605 unmodified lines
modified:tests/flask_tests.py+13 added
855 unmodified lines
856 return flask.render_template('template_filter.html', value='abcd')857 rv = app.test_client().get('/')858 assert rv.data == 'dcba'859860 def test_custom_template_loader(self):861 class MyFlask(flask.Flask):862 def create_jinja_loader(self):863 from jinja2 import DictLoader864 return DictLoader({'index.html': 'Hello Custom World!'})865 app = MyFlask(__name__)866 @app.route('/')867 def index():868 return flask.render_template('index.html')869 c = app.test_client()870 rv = c.get('/')871 assert rv.data == 'Hello Custom World!'872873874class ModuleTestCase(unittest.TestCase):875876 def test_basic_module(self):877 app = flask.Flask(__name__)
623 unmodified lines
modified:CHANGES+1 added
33 unmodified lines
34 allows one to register a callback to an arbitrary endpoint with35 a decorator.36- Use Last-Modified for static file sending instead of Date which37 was incorrectly introduced in 0.6.38- Added `create_jinja_loader` to override the loader creation process.3940Version 0.6.141-------------42
159 unmodified lines