Skip to content

Update asset_management.rst #4839

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

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions cookbook/assetic/asset_management.rst
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@ directly:

.. code-block:: html+jinja

<script src="{{ asset('js/script.js') }}" type="text/javascript"></script>
<script src="{{ asset('js/script.js') }}"></script>

.. code-block:: php

<script src="<?php echo $view['assets']->getUrl('js/script.js') ?>" type="text/javascript"></script>
<script src="<?php echo $view['assets']->getUrl('js/script.js') ?>"></script>

But *with* Assetic, you can manipulate these assets however you want (or
load them from anywhere) before serving them. This means you can:
Expand Down Expand Up @@ -60,15 +60,15 @@ To include JavaScript files, use the ``javascripts`` tag in any template:
.. code-block:: html+jinja

{% javascripts '@AcmeFooBundle/Resources/public/js/*' %}
<script type="text/javascript" src="{{ asset_url }}"></script>
<script src="{{ asset_url }}"></script>
{% endjavascripts %}

.. code-block:: html+php

<?php foreach ($view['assetic']->javascripts(
array('@AcmeFooBundle/Resources/public/js/*')
) as $url): ?>
<script type="text/javascript" src="<?php echo $view->escape($url) ?>"></script>
<script src="<?php echo $view->escape($url) ?>"></script>
<?php endforeach ?>

.. note::
Expand All @@ -82,7 +82,7 @@ To include JavaScript files, use the ``javascripts`` tag in any template:
{# ... #}
{% block javascripts %}
{% javascripts '@AcmeFooBundle/Resources/public/js/*' %}
<script type="text/javascript" src="{{ asset_url }}"></script>
<script src="{{ asset_url }}"></script>
{% endjavascripts %}
{% endblock %}
{# ... #}
Expand Down Expand Up @@ -548,7 +548,7 @@ command will automatically regenerate assets *as they change*:
$ php app/console assetic:dump --watch

Since running this command in the ``dev`` environment may generate a bunch
of files, it's usually a good idea to point your generated assets files to
of files, it's usually a good idea to point your generated asset files to
some isolated directory (e.g. ``/js/compiled``), to keep things organized:

.. configuration-block::
Expand Down