是否有可能将带有assetic过滤器定义的服务文件作为YML文件包含在config.yml中?Assetic期望XML结构...
bundle/Resources/config/services.yml:
assetic.filter.csslint:
class: IOKI\CommonBundle\Assetic\Filter\CssLintFilter
tags:
- { name: assetic.filter, alias: csslint}config.yml
assetic:
filters:
csslint:
resource: %kernel.root_dir%/../src/Project/CommonBundle/Resources/config/services.yml发布于 2015-07-30 20:07:13
a related issue与Assetic的讨论暗示您可以将XML键指向任意的resource文件(这里的示例使用'assetic.xml',然后可以正常地在services.yml中指定您的过滤器。
(我发现,只有当我清除Symfony缓存并在浏览器中进行“硬刷新”时,这种方法才能起作用-直到我尝试了一下,它才真正对我起作用。)
此外,如果您只想直接从模板而不是在config.yml中引用筛选器,则根本不需要在config.yml中提及它。您可以像以前一样在services.yml中指定过滤器,然后在Twig中引用它。例如:
{% stylesheets
'bundles/boardworksapp/less/custom.less' filter='csslint'
%}
<link rel="stylesheet" href="{{ asset_url }}" />
{% endstylesheets %}https://stackoverflow.com/questions/15483963
复制相似问题