-
-
Notifications
You must be signed in to change notification settings - Fork 5.2k
Assetic fixes #1991
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Assetic fixes #1991
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -76,6 +76,23 @@ drawn from various sources such as from within a bundle: | |
<link rel="stylesheet" href="<?php echo $view->escape($url) ?>" /> | ||
<?php endforeach; ?> | ||
|
||
.. 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%" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's in the config like this in the standard distribution though so its in keeping with that There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Small detail either way, but what I'd love the most is to use the
Also, is this new note actually correct yet? My impression is that you don't need to add your bundle to the If I'm wrong, some please shout at me! :) I just wanted to make sure we were clear on that before merging. Thanks! There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
I strongly suspect that you are correct. It makes a lot more sense to me now. I’ll make some tests next week and rewrite accordingly. |
||
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: | ||
|
@@ -87,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/*' | ||
%} | ||
<link rel="stylesheet" href="{{ asset_url }}" /> | ||
{% endstylesheets %} | ||
|
||
.. code-block:: html+php | ||
|
||
<?php foreach ($view['assetic']->stylesheets( | ||
array('@AcmeFooBundle/Resources/public/css/*'), | ||
array(), | ||
array('output' => 'bundles/acmefoo/css/compiled.css') | ||
) as $url): ?> | ||
<link rel="stylesheet" href="<?php echo $view->escape($url) ?>" /> | ||
<?php endforeach; ?> | ||
|
||
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*. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I actually didn't know that you could work around this problem by changing the output to a path in the bundle. It's interesting, but I think that we should just tell people to not use the So, can you rebase against the latest changes, then simple mention the problem with using the Thanks! There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No problem, I’ll do that. |
||
|
||
Combining Assets | ||
~~~~~~~~~~~~~~~~ | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please don't advocate removing the list entirely, as it mean AsseticBundle would scan all bundles for assetic tags, which is slow
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK, I didn’t know. Will fix.