Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit e03cc06

Browse filesBrowse files
gm-olivierweaverryan
authored andcommitted
Added information about the cssrewrite filter not working with the @AcmeFooBundle syntax. [kriswallsmith/assetic#53]
kriswallsmith/assetic#53 (comment)
1 parent d0ccf59 commit e03cc06
Copy full SHA for e03cc06

File tree

Expand file treeCollapse file tree

1 file changed

+33
-1
lines changed
Filter options
Expand file treeCollapse file tree

1 file changed

+33
-1
lines changed

‎cookbook/assetic/asset_management.rst

Copy file name to clipboardExpand all lines: cookbook/assetic/asset_management.rst
+33-1Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,10 +88,42 @@ The actual rendered tag might simply look like:
8888
.. note::
8989

9090
This is a key point: once you let Assetic handle your assets, the files are
91-
served from a different location. This *can* cause problems with CSS files
91+
served from a different location. This *will* cause problems with CSS files
9292
that reference images by their relative path. However, this can be fixed
9393
by using the ``cssrewrite`` filter, which updates paths in CSS files
9494
to reflect their new location.
95+
96+
Unfortunately, the ``cssrewrite`` filter does not work when using the
97+
``@AcmeFooBundle`` syntax to reference the assets. This is a known
98+
limitation. A workaround is to use the ``output`` option to change the
99+
location the files are served from to a path from which the relative paths
100+
work, e.g.:
101+
102+
.. configuration-block::
103+
104+
.. code-block:: html+jinja
105+
106+
{% stylesheets
107+
output='bundles/acmefoo/css/compiled.css'
108+
'@AcmeFooBundle/Resources/public/css/*'
109+
%}
110+
<link rel="stylesheet" href="{{ asset_url }}" />
111+
{% endstylesheets %}
112+
113+
.. code-block:: html+php
114+
115+
<?php foreach ($view['assetic']->stylesheets(
116+
array('@AcmeFooBundle/Resources/public/css/*'),
117+
array(),
118+
array('output' => 'bundles/acmefoo/css/compiled.css')
119+
) as $url): ?>
120+
<link rel="stylesheet" href="<?php echo $view->escape($url) ?>" />
121+
<?php endforeach; ?>
122+
123+
Of course, this assumes that all the CSS files you serve in this block use
124+
relative paths that start from the same location, which is not always
125+
convenient. This is the reason this is called a *workaround* and not a
126+
*solution*.
95127

96128
Combining Assets
97129
~~~~~~~~~~~~~~~~

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.