-
-
Notifications
You must be signed in to change notification settings - Fork 5.2k
Closed
Labels
AssetactionableClear and specific issues ready for anyone to take them.Clear and specific issues ready for anyone to take them.hasPRA Pull Request has already been submitted for this issue.A Pull Request has already been submitted for this issue.
Milestone
Description
The new Asset component has been merged in symfony/symfony#13234.
Todos:
- Document the component (Added the documentation for the new Asset component #4987)
- 1. Changes in configuration
- 2. Changes in Twig templates
- 3. Other changes
1. Changes in configuration
# OLD configuration
framework:
templating:
assets_version: 'v5'
assets_version_format: '%%s?version=%%s'
assets_base_urls:
http: ['http://cdn.example.com']
ssl: ['https://secure.example.com']
packages:
# ...
# NEW configuration
framework:
assets:
version: 'v5'
version_format: '%%s?version=%%s'
base_path: ~
base_urls: ['http://cdn.example.com', 'https://secure.example.com']
packages:
# ...
2. Changes in Twig templates
{{ asset() }}
function is the same as before, but now it only allows to set two arguments:
{# Common case: no package name #}
{{ asset('logo.png') }}
{# When using packages #}
{{ asset('logo.png', 'images') }}
This means that absolute
and version
arguments are no longer available:
{# BEFORE #}
{{ asset('logo.png', absolute = true) }}
{# AFTER #}
{{ absolute_url(asset('logo.png')) }}
{# BEFORE #}
{{ asset('logo.png', version = 'v5') }}
{# AFTER #}
{# relative URLs - do nothing (version is automatically appended) #}
{{ asset('logo.png') }}
{# absolute URLs - get the version with asset_version() and append it manually #}
{{ absolute_url(asset('logo.png')) ~ '?' ~ asset_version('logo.png') }}
3. Other changes
- The
asset*()
functions are now defined in the Twig Bridge instead of the Twig Bundle.
4. Lastly, I have a question when using Asset component in a Symfony application: How can I use a custom version strategy in a Symfony application?
Metadata
Metadata
Assignees
Labels
AssetactionableClear and specific issues ready for anyone to take them.Clear and specific issues ready for anyone to take them.hasPRA Pull Request has already been submitted for this issue.A Pull Request has already been submitted for this issue.