yproximite/asset-dependency-bundle

This package is abandoned and no longer maintained. No replacement package was suggested.
There is no license information available for the latest version (v2.0.0) of this package.

v2.0.0 2017-11-21 15:23 UTC

This package is not auto-updated.

Last update: 2020-01-20 07:25:19 UTC


README

This bundle enables TWIG templates to declare that they need stylesheets and javascripts.

Usage

Twig templates can declare their dependencies like this:

{{ depends_on_stylesheet(['bundles/foobar/css/style.css']) }}
{{ depends_on_javascript(['bundles/foobar/js/jquery.js']) }}

Each dependency is then included once when the response is rendered.

The bundle also allows you to specify aliases in the configuration:

// app/config.yml
ylly_asset_dependency:
    javascript_alias_map:
        jquery: bundles/foobar/js/jquery.js
        jquery-ui: bundles/foobar/js/jquery-ui.js
    stylesheet_alias_map:
        style: bundles/foobar/css/style.css


// sometemplate.html.twig
{{ depends_on_stylesheet(['@style']) }}
{{ depends_on_javascript(['@jquery']) }}

To include the dependencies in your layout insert the following placeholders:

<!-- YLLY_ASSET_DEPENDENCY_STYLESHEETS !-->
<!-- YLLY_ASSET_DEPENDENCY_JAVASCRIPTS !-->