Thanks to visit codestin.com
Credit goes to github.com

Skip to content

[Templating] Adding AssetMapper to asset() function #21132

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

Open
wants to merge 1 commit into
base: 6.4
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions templates.rst
Original file line number Diff line number Diff line change
Expand Up @@ -312,8 +312,12 @@ You can now use the ``asset()`` function:
{# the JS file lives at "public/bundles/acme/js/loader.js" #}
<script src="{{ asset('bundles/acme/js/loader.js') }}"></script>

The ``asset()`` function's main purpose is to make your application more portable.
If your application lives at the root of your host (e.g. ``https://example.com``),
Using the ``asset()`` function is recommended for two reasons:

* It automatically takes care of versioning your assets with
:doc:`Symfony's AssetMapper </frontend>`

* If your application lives at the root of your host (e.g. ``https://example.com``),
then the rendered path should be ``/images/logo.png``. But if your application
lives in a subdirectory (e.g. ``https://example.com/my_app``), each asset path
should render with the subdirectory (e.g. ``/my_app/images/logo.png``). The
Expand Down