@@ -88,10 +88,42 @@ The actual rendered tag might simply look like:
88
88
.. note ::
89
89
90
90
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
92
92
that reference images by their relative path. However, this can be fixed
93
93
by using the ``cssrewrite `` filter, which updates paths in CSS files
94
94
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 *.
95
127
96
128
Combining Assets
97
129
~~~~~~~~~~~~~~~~
0 commit comments