yproximite / asset-dependency-bundle
Installs: 5 157
Dependents: 0
Suggesters: 0
Security: 0
Stars: 7
Watchers: 11
Forks: 0
Open Issues: 0
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 !-->