SMS*_*MSM 6 css php symfony twig assetic
我使用Symfony2进行多本地化项目,并根据当前用户本地在不同文件夹上分离(CSS/Images).
文件夹结构Ex:
Resources\
public\
css\
ar\
home.css
en\
home.css
Run Code Online (Sandbox Code Playgroud)
**现在我需要Assetic来呈现基于当前用户本地{ar |的正确home.CSS文件 没有丢失树枝和过滤器功能**}
示例 - 这不起作用:
{% stylesheets
'bundles/atcopcore/css/{ app.request.locale }/home.css' filter='cssrewrite'
%}
<link rel="stylesheet" href="{{ asset_url }}" />
Run Code Online (Sandbox Code Playgroud)
注意:我想获得css compine的优势,如果我执行以下操作,则无法执行此操作:
<link rel="stylesheet" href="{{ asset('css/' ~ app.request.locale ~ '/home.css') }}" />
Run Code Online (Sandbox Code Playgroud)
我怎么能这样做......
我发现链接可能很有用,但我认为有更专业的方法来做到这一点.
请问,有什么建议吗?
你也许应该尝试这样的事情:
{% if app.request.locale == "en" %}
{% stylesheets filter='cssrewrite'
'bundles/atcopcore/css/en/home.css'
'bundles/atcopcore/css/en/foo.css'
%}
<link rel="stylesheet" href="{{ asset_url }}" />
{% endstylesheets %}
{% elseif app.request.locale == "fr" %}
{% stylesheets filter='cssrewrite'
'bundles/atcopcore/css/fr/home.css'
'bundles/atcopcore/css/fr/foo.css'
%}
<link rel="stylesheet" href="{{ asset_url }}" />
{% endstylesheets %}
{% elseif app.request.locale == "ar" %}
{% stylesheets filter='cssrewrite'
'bundles/atcopcore/css/ar/home.css'
'bundles/atcopcore/css/ar/foo.css'
%}
<link rel="stylesheet" href="{{ asset_url }}" />
{% endstylesheets %}
{% endif %}
Run Code Online (Sandbox Code Playgroud)
它看起来有点冗长,但是这样你的所有 css 文件都会被组合起来,并且好的一个将会提供给用户。
| 归档时间: |
|
| 查看次数: |
964 次 |
| 最近记录: |