我正在使用Symfony2,Assetic和Twig.我有各种前端库 - Backbone,jQuery,jQuery UI和Bootstrap.Bootstrap和jQuery UI都包含CSS和JS文件.
有没有办法可以定义他们需要包含的资源(包括依赖项),然后在Twig/Assetic中将所有这些资源包含在一个标签中?我希望看到的是:
// config.yml <!-- DOES NOT WORK -->
assetic:
resources:
jquery:
js: /filepath/to/jquery.js
jquery_ui:
dependencies: jquery
css: /filepath/to/jqueryui.css
js: /filepath/to/jqueryui.js
less:
js: /filepath/to/less.js
bootstrap:
dependencies: { less, jquery }
js: /filepath/to/bootstrap.js
css: /filepath/to/bootstrap.css
backbone:
dependencies: { jquery }
js: { /filepath/to/underscore.js, /filepath/to/backbone.js }
// view.html.twig
{% use jquery_ui %}
{% use bootstrap %}
// outputs all js and css for jQuery, jQueryUI, Less, Backbone, and Bootstrap
Run Code Online (Sandbox Code Playgroud)
我发现了几个相关的问题:
但似乎都没有涉及在config.yml中定义资源.相反,他们定义了它们, …