-
-
Notifications
You must be signed in to change notification settings - Fork 5.2k
More asset version details #3837
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
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -991,40 +991,43 @@ assets won't be cached when deployed. For example, ``/images/logo.png`` might | |
look like ``/images/logo.png?v2``. For more information, see the :ref:`ref-framework-assets-version` | ||
configuration option. | ||
|
||
.. _` | ||
|
||
.. versionadded:: 2.5 | ||
Absolute URLs for assets were introduced in Symfony 2.5. | ||
Setting versioned URLs on an asset-by-asset basis were introduced in Symfony 2.5. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. shouldn't it be There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 👍 |
||
|
||
If you need absolute URLs for assets, you can set the third argument (or the | ||
``absolute`` argument) to ``true``: | ||
If you need to set a version for a specific asset, you can set the fourth | ||
argument (or the ``version`` argument) to the desired version: | ||
|
||
.. configuration-block:: | ||
|
||
.. code-block:: html+jinja | ||
|
||
<img src="{{ asset('images/logo.png', absolute=true) }}" alt="Symfony!" /> | ||
<img src="{{ asset('images/logo.png', version=3.0) }}" alt="Symfony!" /> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If you want to be consistent with the PHP code, it should be a string here, not a float (the version will be set as |
||
|
||
.. code-block:: html+php | ||
|
||
<img src="<?php echo $view['assets']->getUrl('images/logo.png', null, true) ?>" alt="Symfony!" /> | ||
<img src="<?php echo $view['assets']->getUrl('images/logo.png', null, false, '3.0') ?>" alt="Symfony!" /> | ||
|
||
If you dont give a version or pass ``null``, the default package version | ||
(from :ref:`ref-framework-assets-version`) wil be used. If you pass ``false``, | ||
versioned URL will be deactivated for this asset. | ||
|
||
.. versionadded:: 2.5 | ||
Versioned URLs for assets were introduced in Symfony 2.5. | ||
Absolute URLs for assets were introduced in Symfony 2.5. | ||
|
||
If you need versioned URLs for assets, you can set the fourth argument (or the | ||
``version`` argument) to the desired version: | ||
If you need absolute URLs for assets, you can set the third argument (or the | ||
``absolute`` argument) to ``true``: | ||
|
||
.. configuration-block:: | ||
|
||
.. code-block:: html+jinja | ||
|
||
<img src="{{ asset('images/logo.png', version=3.0) }}" alt="Symfony!" /> | ||
<img src="{{ asset('images/logo.png', absolute=true) }}" alt="Symfony!" /> | ||
|
||
.. code-block:: html+php | ||
|
||
<img src="<?php echo $view['assets']->getUrl('images/logo.png', null, false, '3.0') ?>" alt="Symfony!" /> | ||
|
||
If you dont give a version or pass ``null``, the default package version will | ||
be used. If you pass ``false``, versioned URL will be deactivated. | ||
<img src="<?php echo $view['assets']->getUrl('images/logo.png', null, true) ?>" alt="Symfony!" /> | ||
|
||
.. index:: | ||
single: Templating; Including stylesheets and JavaScripts | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what is it ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's the start of what becomes
.. _
book-templating-version-by-asset`` :)