Skip to content

Update apply_to_option.rst #4840

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
14 changes: 7 additions & 7 deletions cookbook/assetic/apply_to_option.rst
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ templates:
.. code-block:: html+jinja

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

.. code-block:: html+php
Expand All @@ -69,7 +69,7 @@ templates:
array('@AcmeFooBundle/Resources/public/js/example.coffee'),
array('coffee')
) as $url): ?>
<script src="<?php echo $view->escape($url) ?>" type="text/javascript"></script>
<script src="<?php echo $view->escape($url) ?>"></script>
<?php endforeach ?>

This is all that's needed to compile this CoffeeScript file and serve it
Expand All @@ -87,7 +87,7 @@ You can also combine multiple CoffeeScript files into a single output file:
{% javascripts '@AcmeFooBundle/Resources/public/js/example.coffee'
'@AcmeFooBundle/Resources/public/js/another.coffee'
filter='coffee' %}
<script src="{{ asset_url }}" type="text/javascript"></script>
<script src="{{ asset_url }}"></script>
{% endjavascripts %}

.. code-block:: html+php
Expand All @@ -99,7 +99,7 @@ You can also combine multiple CoffeeScript files into a single output file:
),
array('coffee')
) as $url): ?>
<script src="<?php echo $view->escape($url) ?>" type="text/javascript"></script>
<script src="<?php echo $view->escape($url) ?>"></script>
<?php endforeach ?>

Both the files will now be served up as a single file compiled into regular
Expand All @@ -118,7 +118,7 @@ adding the JavaScript files to the files to be combined as above will not
work as the regular JavaScript files will not survive the CoffeeScript compilation.

This problem can be avoided by using the ``apply_to`` option in the config,
which allows you to specify that a filter should always be applied to particular
which allows you to specify which filter should always be applied to particular
file extensions. In this case you can specify that the ``coffee`` filter is
applied to all ``.coffee`` files:

Expand Down Expand Up @@ -173,7 +173,7 @@ being run through the CoffeeScript filter):
{% javascripts '@AcmeFooBundle/Resources/public/js/example.coffee'
'@AcmeFooBundle/Resources/public/js/another.coffee'
'@AcmeFooBundle/Resources/public/js/regular.js' %}
<script src="{{ asset_url }}" type="text/javascript"></script>
<script src="{{ asset_url }}"></script>
{% endjavascripts %}

.. code-block:: html+php
Expand All @@ -185,5 +185,5 @@ being run through the CoffeeScript filter):
'@AcmeFooBundle/Resources/public/js/regular.js',
)
) as $url): ?>
<script src="<?php echo $view->escape($url) ?>" type="text/javascript"></script>
<script src="<?php echo $view->escape($url) ?>"></script>
<?php endforeach ?>