Skip to content

Commit a5d5b4e

Browse files
committed
minor #21132 [Templating] Adding AssetMapper to asset() function (ThomasLandauer)
This PR was merged into the 6.4 branch. Discussion ---------- [Templating] Adding AssetMapper to `asset()` function Page: https://symfony.com/doc/6.4/templates.html#linking-to-css-javascript-and-image-assets There is another link to AssetMapper just one screen further down - maybe you want to merge them somehow: https://symfony.com/doc/6.4/templates.html#build-versioning-more-advanced-css-javascript-and-image-handling My point here is that the main advantage of the `asset()` function IMO is not the subdirectory scenario, but rather: If you *later* switch to AssetMapper, it saves you a lot of time if you've already used `asset()` everywhere. Commits ------- 117be68 [Templating] Adding AssetMapper to `asset()` function
2 parents d9e3ec2 + 117be68 commit a5d5b4e

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

templates.rst

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -312,8 +312,12 @@ You can now use the ``asset()`` function:
312312
{# the JS file lives at "public/bundles/acme/js/loader.js" #}
313313
<script src="{{ asset('bundles/acme/js/loader.js') }}"></script>
314314

315-
The ``asset()`` function's main purpose is to make your application more portable.
316-
If your application lives at the root of your host (e.g. ``https://example.com``),
315+
Using the ``asset()`` function is recommended for two reasons:
316+
317+
* It automatically takes care of versioning your assets with
318+
:doc:`Symfony's AssetMapper </frontend>`
319+
320+
* If your application lives at the root of your host (e.g. ``https://example.com``),
317321
then the rendered path should be ``/images/logo.png``. But if your application
318322
lives in a subdirectory (e.g. ``https://example.com/my_app``), each asset path
319323
should render with the subdirectory (e.g. ``/my_app/images/logo.png``). The

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy