更新时间:2023-11-19 21:33:46
经过几天的搜索,我发现AsseticBundle
After many days searching I found the packages option on AsseticBundle
http://symfony.com/doc/2.0/reference/configuration/framework.html#full-default-configuration
使用该配置选项,我可以执行以下操作:
Using that config option I could do something like this:
{% javascripts file package='packageName' %}
或
{{asset(file,packageName)}}
config.yml
framework:
templating:
engines: ['twig']
assets_version: %assets_version%
assets_version_format: "stv%%2$s/%%1$s"
packages:
css:
version: 6.1
version_format: "stv%%2$s/%%1$s"
jsApp:
version: 4.2
version_format: "stv%%2$s/%%1$s"
sometemplate.html.twig
<link rel=stylesheet href='{{ asset('bundles/webapp/css/funCommon.css','css') }}'>
{% javascripts 'bundles/webapp/js/app.js'
'bundles/webapp/js/utils.js'
filter='?closure'
package='jsApp'
%}
<script src="{{ asset_url }}"></script>
{% endjavascripts %}
此输出为:
<link rel=stylesheet href="http://static.domain.com/stv6.1/css/HASH.css">
<script src="http://static.domain.com/stv4.2/js/HASH.js"></script>
对我来说,这是按文件管理资产版本的最简单方法.
For me that was the simplest way to manage assets version by file.