Skip to content

Commit cd0efed

Browse files
author
Henry Snoek
committed
[WIP] moving assets version and version_format options under assets section
1 parent 8966d40 commit cd0efed

File tree

5 files changed

+42
-30
lines changed

5 files changed

+42
-30
lines changed

book/templating.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1064,7 +1064,7 @@ being used and generating the correct paths accordingly.
10641064
Additionally, if you use the ``asset`` function, Symfony can automatically
10651065
append a query string to your asset, in order to guarantee that updated static
10661066
assets won't be cached when deployed. For example, ``/images/logo.png`` might
1067-
look like ``/images/logo.png?v2``. For more information, see the :ref:`ref-framework-assets-version`
1067+
look like ``/images/logo.png?v2``. For more information, see the :ref:`reference-framework-assets-version`
10681068
configuration option.
10691069

10701070
.. _`book-templating-version-by-asset`:
@@ -1088,7 +1088,7 @@ if you are using Twig (or the fourth argument if you are using PHP) to the desir
10881088
) ?>" alt="Symfony!" />
10891089

10901090
If you don't give a version or pass ``null``, the default package version
1091-
(from :ref:`ref-framework-assets-version`) will be used. If you pass ``false``,
1091+
(from :ref:`reference-framework-assets-version`) will be used. If you pass ``false``,
10921092
versioned URL will be deactivated for this asset.
10931093

10941094
If you need absolute URLs for assets, you can set the ``absolute`` argument

cookbook/assetic/asset_management.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -472,7 +472,7 @@ done from the template and is relative to the public document root:
472472
Symfony also contains a method for cache *busting*, where the final URL
473473
generated by Assetic contains a query parameter that can be incremented
474474
via configuration on each deployment. For more information, see the
475-
:ref:`ref-framework-assets-version` configuration option.
475+
:ref:`reference-framework-assets-version` configuration option.
476476

477477
.. _cookbook-assetic-dumping:
478478

reference/configuration/assetic.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ Full Default Configuration
5050
some_filter: []
5151
workers:
5252
# see https://github.com/symfony/AsseticBundle/pull/119
53-
# Cache can also be busted via the framework.templating.assets_version
53+
# Cache can also be busted via the framework.assets.version
5454
# setting - see the "framework" configuration section
5555
cache_busting:
5656
enabled: false

reference/configuration/framework.rst

Lines changed: 37 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -69,9 +69,10 @@ Configuration
6969
* `gc_probability`_
7070
* `gc_maxlifetime`_
7171
* `save_path`_
72+
* `assets`_
73+
* `version`_
74+
* `version_format`_
7275
* `templating`_
73-
* `assets_version`_
74-
* `assets_version_format`_
7576
* `hinclude_default_template`_
7677
* :ref:`form <reference-templating-form>`
7778
* `resources`_
@@ -850,14 +851,13 @@ setting the value to ``null``:
850851
),
851852
));
852853
853-
templating
854-
~~~~~~~~~~
854+
assets
855+
~~~~~~
855856

856857
.. _reference-framework-assets-version:
857-
.. _ref-framework-assets-version:
858858

859-
assets_version
860-
..............
859+
version
860+
.......
861861

862862
**type**: ``string``
863863

@@ -879,7 +879,7 @@ For example, suppose you have the following:
879879
<img src="<?php echo $view['assets']->getUrl('images/logo.png') ?>" alt="Symfony!" />
880880
881881
By default, this will render a path to your image such as ``/images/logo.png``.
882-
Now, activate the ``assets_version`` option:
882+
Now, activate the ``version`` option:
883883

884884
.. configuration-block::
885885

@@ -888,7 +888,10 @@ Now, activate the ``assets_version`` option:
888888
# app/config/config.yml
889889
framework:
890890
# ...
891-
templating: { engines: ['twig'], assets_version: v2 }
891+
assets:
892+
version: 'v2'
893+
templating:
894+
engines: ['twig']
892895
893896
.. code-block:: xml
894897
@@ -900,7 +903,8 @@ Now, activate the ``assets_version`` option:
900903
xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd
901904
http://symfony.com/schema/dic/symfony http://symfony.com/schema/dic/symfony/symfony-1.0.xsd">
902905
903-
<framework:templating assets-version="v2">
906+
<framework:assets version="v2">
907+
<framework:templating>
904908
<!-- ... -->
905909
<framework:engine>twig</framework:engine>
906910
</framework:templating>
@@ -911,40 +915,42 @@ Now, activate the ``assets_version`` option:
911915
// app/config/config.php
912916
$container->loadFromExtension('framework', array(
913917
// ...
914-
'templating' => array(
915-
'engines' => array('twig'),
916-
'assets_version' => 'v2',
918+
'assets' => array(
919+
'version' => 'v2',
920+
),
921+
'templating' => array(
922+
'engines' => array('twig'),
917923
),
918924
));
919925
920926
Now, the same asset will be rendered as ``/images/logo.png?v2`` If you use
921-
this feature, you **must** manually increment the ``assets_version`` value
927+
this feature, you **must** manually increment the ``version`` value
922928
before each deployment so that the query parameters change.
923929

924930
It's also possible to set the version value on an asset-by-asset basis (instead
925931
of using the global version - e.g. ``v2`` - set here). See
926932
:ref:`Versioning by Asset <book-templating-version-by-asset>` for details.
927933

928-
You can also control how the query string works via the `assets_version_format`_
934+
You can also control how the query string works via the `version_format`_
929935
option.
930936

931937
.. tip::
932938

933939
As with all settings, you can use a parameter as value for the
934-
``assets_version``. This makes it easier to increment the cache on each
940+
``version``. This makes it easier to increment the cache on each
935941
deployment.
936942

937-
.. _reference-templating-version-format:
943+
.. _reference-assets-version-format:
938944

939-
assets_version_format
940-
.....................
945+
version_format
946+
..............
941947

942948
**type**: ``string`` **default**: ``%%s?%%s``
943949

944950
This specifies a :phpfunction:`sprintf` pattern that will be used with the
945-
`assets_version`_ option to construct an asset's path. By default, the pattern
951+
`version`_ option to construct an asset's path. By default, the pattern
946952
adds the asset's version as a query string. For example, if
947-
``assets_version_format`` is set to ``%%s?version=%%s`` and ``assets_version``
953+
``version_format`` is set to ``%%s?version=%%s`` and ``version``
948954
is set to ``5``, the asset's path would be ``/images/logo.png?version=5``.
949955

950956
.. note::
@@ -957,7 +963,7 @@ is set to ``5``, the asset's path would be ``/images/logo.png?version=5``.
957963

958964
Some CDN's do not support cache-busting via query strings, so injecting
959965
the version into the actual file path is necessary. Thankfully,
960-
``assets_version_format`` is not limited to producing versioned query
966+
``version_format`` is not limited to producing versioned query
961967
strings.
962968

963969
The pattern receives the asset's original path and version as its first
@@ -973,6 +979,9 @@ is set to ``5``, the asset's path would be ``/images/logo.png?version=5``.
973979
any URL rewriting. The latter option is useful if you would like older
974980
asset versions to remain accessible at their original URL.
975981

982+
templating
983+
~~~~~~~~~~
984+
976985
hinclude_default_template
977986
.........................
978987

@@ -1277,7 +1286,7 @@ Each package can configure the following options:
12771286

12781287
* :ref:`base_urls <reference-templating-base-urls>`
12791288
* :ref:`version <reference-framework-assets-version>`
1280-
* :ref:`version_format <reference-templating-version-format>`
1289+
* :ref:`version_format <reference-assets-version-format>`
12811290

12821291
translator
12831292
~~~~~~~~~~
@@ -1589,10 +1598,13 @@ Full Default Configuration
15891598
serializer:
15901599
enabled: false
15911600
1601+
# assets configuration
1602+
assets:
1603+
version: ~
1604+
version_format: '%%s?%%s'
1605+
15921606
# templating configuration
15931607
templating:
1594-
assets_version: ~
1595-
assets_version_format: '%%s?%%s'
15961608
hinclude_default_template: ~
15971609
form:
15981610
resources:

reference/twig_reference.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ asset
111111

112112
Returns a public path to ``path``, which takes into account the base path
113113
set for the package and the URL path. More information in
114-
:ref:`book-templating-assets`. For asset versioning, see :ref:`ref-framework-assets-version`.
114+
:ref:`book-templating-assets`. For asset versioning, see :ref:`reference-framework-assets-version`.
115115

116116
assets_version
117117
~~~~~~~~~~~~~~

0 commit comments

Comments
 (0)