-
-
Notifications
You must be signed in to change notification settings - Fork 16.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Blueprint template lookup not documented enough #266
Comments
When you say documentation, do you mean docstrings in the source and the like, or docs/blueprints.rst? What about them do you wish was clearer? |
This is fixed.
|
http://stackoverflow.com/questions/7974771/flask-blueprint-template-folder/8198325 is this a feature? not a bug |
|
This still confusing. Can you add some examples in the documentation? |
The current documentation (http://flask.pocoo.org/docs/blueprints/#templates) is still confusing. It should state that the reason we have to render 'admin/index.html' instead of 'index.html' is to avoid name conflict. However, I would consider http://stackoverflow.com/questions/7974771/flask-blueprint-template-folder/8198325 a bug. |
@rduplain I have been struggling with this BUG for an hour. And It is so not a feature. At least, there should be some argument could be set to make the higher priority of template_folder. PS. How to print the current searchpath of templates? |
Reopening because of doc issues. |
it's a BUG. |
It is not a bug per se. But it does depend a lot on how your application is structured whether it is useful or not - in my opinon it's not useful in most cases and having the blueprint name automatically included in the template folder would make sense. Luckily you can easily implement this for yourself in an even more flexible way than just using the blueprint name. You can find an example here (the (I wouldn't mind to have an option for this in Flask itself, since that way IDEs like PyCharm would be likely to support it instead of not being able to show me a link to edit the template a view function is rendering) |
I'm running into the same issue as http://stackoverflow.com/questions/7974771/flask-blueprint-template-folder/8198325 It makes sense to be able to override a blueprint's template in the main template folder, but rendering another blueprint's template due to the template search path order seems buggy to me. Using the facebook example from https://exploreflask.com/blueprints.html#which-one-is-best: |
I just ran into this issue today - not the documentation issue posted by OP, but the one referred to in the stackoverflow question linked to above, and discussed later on in these comments. I agree with @TRII - overriding a blueprint's template from below it on the tree makes sense, but it seems wrong that templates from different blueprints conflict with each other. When you're loading a template with Reading and thinking more, I think I've figured out how it works: there is a global namespace for templates, and each blueprint's templates folder is at the root of that namespace. It's a simple system, which is nice, but it means that if you want to have your templates in their own namespace, you have to put them in a subfolder whose name is unique to the blueprint. In practice you use the name of the blueprint. I guess that's not that bad - the structure of most ruby gems are like this, for example, with The bigger issue is that, in order to refer to a template for your blueprint under this system, you have to use the template's global name ( |
In the blueprints templates documentation mention the possible templates name conflict issue re pallets#266
The new blueprint template lookup scheme where the templates folder is just added to the searchpath instead of doing some weird stuff with the names as before. The documentation has to be clearer about that.
The text was updated successfully, but these errors were encountered: