Some documentation improvements
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 60e143e · Browse files · 2 files·+49 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
2 files+49 added−1 removed
- other:+49 added−1 removed
Provenance
- Commit
77743a5- Tree
1e6d64c- Author
Armin Ronacher <armin.ronacher@active-4.com>- Committer
Armin Ronacher <armin.ronacher@active-4.com>- Parent
60e143e
2 files changed+49 added−1 removed
modified:docs/patterns/packages.rst+46 added
195 unmodified lines196 197 @frontend.route('/')198 def index():199 return "I'm the index"200+201+.. _modules-and-resources:202+203+Modules and Resources204+---------------------205+206+.. versionadded:: 0.5207+208+If a module is located inside an actual Python package it may contain209+static files and templates. Imagine you have an application like this::210+211+212+ /yourapplication213+ __init__.py214+ /apps215+ /frontend216+ __init__.py217+ views.py218+ /static219+ style.css220+ /templates221+ index.html222+ about.html223+ ...224+ /admin225+ __init__.py226+ views.py227+ /static228+ style.css229+ /templates230+ list_items.html231+ show_item.html232+ ...233+234+The static folders automatically become exposed as URLs. For example if235+the `admin` module is exported with an URL prefix of ``/admin`` you can236+access the style css from its static folder by going to237+``/admin/static/style.css``. The URL endpoint for the static files of the238+admin would be ``'admin.static'``, similar to how you refer to the regular239+static folder of the whole application as ``'static'``.240+241+If you want to refer to the templates you just have to prefix it with the242+name of the module. So for the admin it would be243+``render_template('admin/list_items.html')`` and so on. It is not244+possible to refer to templates without the prefixed modlue name. This is245+explicit unlike URL rules.modified:flask/module.py+3 added-1 removed
88 unmodified lines89 For a gentle introduction into modules, checkout the90 :ref:`working-with-modules` section.91 92 .. versionadded:: 0.593- The `static_path` parameter was added.93+ The `static_path` parameter was added and it's now possible for94+ modules to refer to their own templates and static files. See95+ :ref:`modules-and-resources` for more information.96 97 :param import_name: the name of the Python package or module98 implementing this :class:`Module`.99 :param name: the internal short name for the module. Unless specified105 unmodified lines