Symfony built-in asset with recycling

I have the following code based on Symfony2 docs:

    {% block javascripts %}

        {% javascripts filter="?jsqueeze" output="js/app.js"
            "%kernel.root_dir%/Resources/assets/js/one.js"
            "%kernel.root_dir%/Resources/assets/js/two.js" %}
            <script src="{{ asset_url }}"></script>
        {% endjavascripts %}

    {% endblock %}

which works like a charm.

What i want to do instead

<script src="{{ asset_url }}"></script>

use something like:

<script> ... inline asset contents here ... </script>

I tried asset docs and also dug the AsseticTokenParser and AsseticNode classes, but could not find a variable that refers to the actual file path instead of url.

I usually do this with css, not js, but this should be the same concept.

thanks!

+4
source share
1 answer

In production mode, symfony creates a link to a static file that can be included directly in the template. This file should be generated using the following:

php app/console assetic:dump --env=prod --no-debug

dev , . asset_url URL-, Symfony, , , js/css . -, symfony:

{% render asset_url %}

, , render , prod dev.

, / , .

- dev assetic css/js :

php app/console assetic:watch

include.

, Symfony " ", .

+2
source

Source: https://habr.com/ru/post/1609916/


All Articles