Skip to content

Commit

Permalink
feature #3742 [2.5][Templating] Add documentation about generating ve…
Browse files Browse the repository at this point in the history
…rsioned URLs (romainneutron)

This PR was merged into the master branch.

Discussion
----------

[2.5][Templating] Add documentation about generating versioned URLs

| Q             | A
| ------------- | ---
| Doc fix?      | no
| New docs?     | symfony/symfony#10593
| Applies to    | 2.5+

Commits
-------

f6af251 [Templating] Add documentation about generating versioned URLs
  • Loading branch information
weaverryan committed May 6, 2014
2 parents be6c79d + f6af251 commit a9648e8
Show file tree
Hide file tree
Showing 3 changed files with 102 additions and 71 deletions.
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!" />

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

0 comments on commit a9648e8

Please sign in to comment.