Skip to content
Merged
Show file tree
Hide file tree
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
19 changes: 19 additions & 0 deletions book/templating.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1007,6 +1007,25 @@ If you need absolute URLs for assets, you can set the third argument (or the

<img src="<?php echo $view['assets']->getUrl('images/logo.png', null, true) ?>" alt="Symfony!" />

.. versionadded:: 2.5
Versioned 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:

.. configuration-block::

.. code-block:: html+jinja

<img src="{{ asset('images/logo.png', version=3.0) }}" alt="Symfony!" />
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You should also document null and false.


.. 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.

.. index::
single: Templating; Including stylesheets and JavaScripts
single: Stylesheets; Including stylesheets
Expand Down
12 changes: 12 additions & 0 deletions components/templating/helpers/assetshelper.rst
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,18 @@ is used in :phpfunction:`sprintf`. The first argument is the path and the
second is the version. For instance, ``%s?v=%s`` will be rendered as
``/images/logo.png?v=328rad75``.

.. versionadded:: 2.5
On-demand versioned URLs for assets were introduced in Symfony 2.5.

You can also generate a versioned URL using the fourth argument of the helper:

.. code-block:: html+php

<img src="<?php echo $view['assets']->getUrl('images/logo.png', null, false, '3.0') ?>">
<!-- renders as:
<img src="/images/logo.png?v=3.0">
-->

Multiple Packages
-----------------

Expand Down
Loading