Skip to content
Myr

Fixed a bug in list_templates

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 8d2daea · Browse files · 6 files+23 added−5 removed
This commit

State

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

Diff stats

6 files+23 added−5 removed

  • tests:+12 added−4 removed
  • other:+11 added−1 removed

6 files+23 added−5 removed

modified:flask/templating.py+3 added-1 removed
76 unmodified lines
77 except (ValueError, KeyError):78 pass7980 for blueprint in self.app.blueprints.itervalues():81 if blueprint_is_module(blueprint):82 continue83 loader = blueprint.jinja_loader84 if loader is not None:85 yield loader, template86
7 unmodified lines
94 loader = blueprint.jinja_loader95 if loader is not None:96 for template in loader.list_templates():97 prefix = ''96 if not blueprint_is_module(blueprint):98 if blueprint_is_module(blueprint):99 prefix = name + '/'100 result.add(prefix + template)101102 return list(result)
36 unmodified lines
modified:tests/blueprintapp/apps/admin/__init__.py+3 added-1 removed
1from flask import Blueprint, render_template23admin = Blueprint(__name__, url_prefix='/admin')3admin = Blueprint('admin', __name__, url_prefix='/admin',4 template_folder='templates',5 static_folder='static')678@admin.route('/')9def index():
6 unmodified lines
modified:tests/blueprintapp/apps/frontend/__init__.py+1 added-1 removed
1from flask import Blueprint, render_template23frontend = Blueprint(__name__)3frontend = Blueprint('frontend', __name__, template_folder='templates')456@frontend.route('/')7def index():
1 unmodified line
modified:tests/blueprintapp/__init__.py+2 added-2 removed
1from flask import Flask23app = Flask(__name__)4from moduleapp.apps.admin import admin5from moduleapp.apps.frontend import frontend4from blueprintapp.apps.admin import admin5from blueprintapp.apps.frontend import frontend6app.register_blueprint(admin)7app.register_blueprint(frontend)
modified:tests/flask_tests.py+6 added
1412 unmodified lines
14131414 with flask.Flask(__name__).test_request_context():1415 assert flask.render_template('nested/nested.txt') == 'I\'m nested'14161417 def test_templates_list(self):1418 from blueprintapp import app1419 templates = sorted(app.jinja_env.list_templates())1420 self.assertEqual(templates, ['admin/index.html',1421 'frontend/index.html'])14221423 def test_dotted_names(self):1424 frontend = flask.Blueprint('myapp.frontend', __name__)1425 backend = flask.Blueprint('myapp.backend', __name__)1426
547 unmodified lines
modified:CHANGES+8 added
13 unmodified lines
14- Empty session cookies are now deleted properly automatically.15- View functions can now opt out of getting the automatic16 OPTIONS implementation.1718Version 0.7.319-------------2021Bugfix release, release date to be decided2223- Fixed the Jinja2 environment's list_templates method not returning the24 correct names when blueprints or modules were involved.2526Version 0.7.227-------------2829Bugfix release, released on July 6th 2011
229 unmodified lines