From c2c308f9c0a41426113e4f2aaa7476ca0f05527f Mon Sep 17 00:00:00 2001 From: Olivier Date: Thu, 29 Nov 2012 09:26:54 +0100 Subject: [PATCH 1/3] Added mention about the bundles configuration option. It is empty by default on new Symfony installations, which prevents all the @AsseticFooBundle examples from working. --- cookbook/assetic/asset_management.rst | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/cookbook/assetic/asset_management.rst b/cookbook/assetic/asset_management.rst index c541be4ac64..4d592453c25 100644 --- a/cookbook/assetic/asset_management.rst +++ b/cookbook/assetic/asset_management.rst @@ -76,6 +76,23 @@ drawn from various sources such as from within a bundle: +.. tip:: + + For the above example to work, you must either add your bundle to the list + of bundles that Assetic is allowed to handle (which is *none* in a default + Symfony installation), or remove the bundle list from the configuration + altogether: + + .. code-block:: yaml + + # app/config/config.yml + assetic: + debug: "%kernel.debug%" + use_controller: false + #bundles: [ ] + filters: + # ... + In this example, all of the files in the ``Resources/public/js/`` directory of the ``AcmeFooBundle`` will be loaded and served from a different location. The actual rendered tag might simply look like: From 2120f4746874883611dfd196cc5560ec454e1fb1 Mon Sep 17 00:00:00 2001 From: Olivier Date: Thu, 29 Nov 2012 09:33:51 +0100 Subject: [PATCH 2/3] Added information about the cssrewrite filter not working with the @AcmeFooBundle syntax. [kriswallsmith/assetic#53] https://github.com/kriswallsmith/assetic/issues/53#issuecomment-2976018 --- cookbook/assetic/asset_management.rst | 34 ++++++++++++++++++++++++++- 1 file changed, 33 insertions(+), 1 deletion(-) diff --git a/cookbook/assetic/asset_management.rst b/cookbook/assetic/asset_management.rst index 4d592453c25..59cf87ac629 100644 --- a/cookbook/assetic/asset_management.rst +++ b/cookbook/assetic/asset_management.rst @@ -104,10 +104,42 @@ The actual rendered tag might simply look like: .. note:: This is a key point: once you let Assetic handle your assets, the files are - served from a different location. This *can* cause problems with CSS files + served from a different location. This *will* cause problems with CSS files that reference images by their relative path. However, this can be fixed by using the ``cssrewrite`` filter, which updates paths in CSS files to reflect their new location. + + Unfortunately, the ``cssrewrite`` filter does not work when using the + ``@AcmeFooBundle`` syntax to reference the assets. This is a known + limitation. A workaround is to use the ``output`` option to change the + location the files are served from to a path from which the relative paths + work, e.g.: + + .. configuration-block:: + + .. code-block:: html+jinja + + {% stylesheets + output='bundles/acmefoo/css/compiled.css' + '@AcmeFooBundle/Resources/public/css/*' + %} + + {% endstylesheets %} + + .. code-block:: html+php + + stylesheets( + array('@AcmeFooBundle/Resources/public/css/*'), + array(), + array('output' => 'bundles/acmefoo/css/compiled.css') + ) as $url): ?> + + + + Of course, this assumes that all the CSS files you serve in this block use + relative paths that start from the same location, which is not always + convenient. This is the reason this is called a *workaround* and not a + *solution*. Combining Assets ~~~~~~~~~~~~~~~~ From 1e219c96e30b64eb2848d9fe43a23d1bd537af75 Mon Sep 17 00:00:00 2001 From: Olivier Date: Thu, 29 Nov 2012 10:34:37 +0100 Subject: [PATCH 3/3] =?UTF-8?q?Don=E2=80=99t=20suggest=20that=20it?= =?UTF-8?q?=E2=80=99s=20a=20good=20idea=20to=20remove=20the=20list=20of=20?= =?UTF-8?q?bundles=20entirely.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- cookbook/assetic/asset_management.rst | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/cookbook/assetic/asset_management.rst b/cookbook/assetic/asset_management.rst index 59cf87ac629..47dbced3b43 100644 --- a/cookbook/assetic/asset_management.rst +++ b/cookbook/assetic/asset_management.rst @@ -78,10 +78,8 @@ drawn from various sources such as from within a bundle: .. tip:: - For the above example to work, you must either add your bundle to the list - of bundles that Assetic is allowed to handle (which is *none* in a default - Symfony installation), or remove the bundle list from the configuration - altogether: + For the above example to work, you must also add your bundle to the list + of bundles that Assetic handles, which is empty by default: .. code-block:: yaml @@ -89,7 +87,7 @@ drawn from various sources such as from within a bundle: assetic: debug: "%kernel.debug%" use_controller: false - #bundles: [ ] + bundles: [ AcmeFooBundle ] filters: # ...