forked from orbit-oss/flask
Fixed a bug in list_templates
This commit is contained in:
parent
8d2daea327
commit
c9a2ad2b8d
6 changed files with 23 additions and 5 deletions
8
CHANGES
8
CHANGES
|
|
@ -15,6 +15,14 @@ Relase date to be decided, codename to be chosen.
|
||||||
- View functions can now opt out of getting the automatic
|
- View functions can now opt out of getting the automatic
|
||||||
OPTIONS implementation.
|
OPTIONS implementation.
|
||||||
|
|
||||||
|
Version 0.7.3
|
||||||
|
-------------
|
||||||
|
|
||||||
|
Bugfix release, release date to be decided
|
||||||
|
|
||||||
|
- Fixed the Jinja2 environment's list_templates method not returning the
|
||||||
|
correct names when blueprints or modules were involved.
|
||||||
|
|
||||||
Version 0.7.2
|
Version 0.7.2
|
||||||
-------------
|
-------------
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -78,6 +78,8 @@ class DispatchingJinjaLoader(BaseLoader):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
for blueprint in self.app.blueprints.itervalues():
|
for blueprint in self.app.blueprints.itervalues():
|
||||||
|
if blueprint_is_module(blueprint):
|
||||||
|
continue
|
||||||
loader = blueprint.jinja_loader
|
loader = blueprint.jinja_loader
|
||||||
if loader is not None:
|
if loader is not None:
|
||||||
yield loader, template
|
yield loader, template
|
||||||
|
|
@ -93,7 +95,7 @@ class DispatchingJinjaLoader(BaseLoader):
|
||||||
if loader is not None:
|
if loader is not None:
|
||||||
for template in loader.list_templates():
|
for template in loader.list_templates():
|
||||||
prefix = ''
|
prefix = ''
|
||||||
if not blueprint_is_module(blueprint):
|
if blueprint_is_module(blueprint):
|
||||||
prefix = name + '/'
|
prefix = name + '/'
|
||||||
result.add(prefix + template)
|
result.add(prefix + template)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
from flask import Flask
|
from flask import Flask
|
||||||
|
|
||||||
app = Flask(__name__)
|
app = Flask(__name__)
|
||||||
from moduleapp.apps.admin import admin
|
from blueprintapp.apps.admin import admin
|
||||||
from moduleapp.apps.frontend import frontend
|
from blueprintapp.apps.frontend import frontend
|
||||||
app.register_blueprint(admin)
|
app.register_blueprint(admin)
|
||||||
app.register_blueprint(frontend)
|
app.register_blueprint(frontend)
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,8 @@
|
||||||
from flask import Blueprint, render_template
|
from flask import Blueprint, render_template
|
||||||
|
|
||||||
admin = Blueprint(__name__, url_prefix='/admin')
|
admin = Blueprint('admin', __name__, url_prefix='/admin',
|
||||||
|
template_folder='templates',
|
||||||
|
static_folder='static')
|
||||||
|
|
||||||
|
|
||||||
@admin.route('/')
|
@admin.route('/')
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
from flask import Blueprint, render_template
|
from flask import Blueprint, render_template
|
||||||
|
|
||||||
frontend = Blueprint(__name__)
|
frontend = Blueprint('frontend', __name__, template_folder='templates')
|
||||||
|
|
||||||
|
|
||||||
@frontend.route('/')
|
@frontend.route('/')
|
||||||
|
|
|
||||||
|
|
@ -1414,6 +1414,12 @@ class BlueprintTestCase(unittest.TestCase):
|
||||||
with flask.Flask(__name__).test_request_context():
|
with flask.Flask(__name__).test_request_context():
|
||||||
assert flask.render_template('nested/nested.txt') == 'I\'m nested'
|
assert flask.render_template('nested/nested.txt') == 'I\'m nested'
|
||||||
|
|
||||||
|
def test_templates_list(self):
|
||||||
|
from blueprintapp import app
|
||||||
|
templates = sorted(app.jinja_env.list_templates())
|
||||||
|
self.assertEqual(templates, ['admin/index.html',
|
||||||
|
'frontend/index.html'])
|
||||||
|
|
||||||
def test_dotted_names(self):
|
def test_dotted_names(self):
|
||||||
frontend = flask.Blueprint('myapp.frontend', __name__)
|
frontend = flask.Blueprint('myapp.frontend', __name__)
|
||||||
backend = flask.Blueprint('myapp.backend', __name__)
|
backend = flask.Blueprint('myapp.backend', __name__)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue