-
-
Notifications
You must be signed in to change notification settings - Fork 5.2k
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
Document the new Asset component + framework changes #4982
Comments
Thank you for taking care of this @javiereguiluz |
The component's readme can be used as a starting point for this. |
…viereguiluz) This PR was submitted for the master branch but it was merged into the 2.7 branch instead (closes #4987). Discussion ---------- Added the documentation for the new Asset component | Q | A | ------------- | --- | Doc fix? | no | New docs? | yes | Applies to | 2.7+ | Fixed tickets | #4982 This PR only adds the "Symfony-agnostic" documentation. After this doc is merged, we have to update the rest of the Symfony documentation with the following changes: ----- **1. Changes in configuration** ```yaml # 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: ```twig {# 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: ```twig {# 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. * ... ----- 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? Commits ------- 7ab379a Lots of fixes and rewordings 9e8de96 Fixed RST syntax issues 5ca85d1 Fixed some RST syntax issues 17269a3 Moved the component documentation to its own folder fab3c89 Fixed a lot of errors and added an introduction 49548b3 Tweaked documentation and added links to API methods/classes 76b8bea Added a missing link reference d39b26e Minor rewording 6d367b1 Added the documentation for the new Asset component
This PR was merged into the 2.7 branch. Discussion ---------- Proofreading tweaks to asset component This follows after #4987 - all pretty minor. | Q | A | ------------- | --- | Doc fix? | no | New docs? | no | Applies to | 2.7+ | Fixed tickets | Works towards #4982 Commits ------- 59325ee Changes thanks to WouterJ and xabbuh 110efab [#4987] Proofreading tweaks to asset component
Reopening as I think we still have to cover the other three items. @wouterj Please let me know if you disagree. |
Oh, I was to quick. ✋ Thanks for reviewing my actions, @xabbuh. |
Regarding changes in Twig templates, |
…z, WouterJ) This PR was merged into the 2.7 branch. Discussion ---------- [2.7] Update Twig docs for asset features Finishes #5171 | Q | A | ------------- | --- | Doc fix? | yes | New docs? | no | Applies to | 2.7+ | Fixed tickets | #4982 (partially) Commits ------- 0cd7e6c Correctly document new twig functions bc18ff1 Updated Twig template to take into account asset() function changes
The new Asset component has been merged in symfony/symfony#13234.
Todos:
1. Changes in configuration
2. Changes in Twig templates
{{ asset() }}
function is the same as before, but now it only allows to set two arguments:This means that
absolute
andversion
arguments are no longer available:3. Other changes
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?
The text was updated successfully, but these errors were encountered: