php - 将变量传递给 Symfony2 中的 Assetic Assets URL

标签 php symfony assetic

有没有办法将变量传递给模板中的 Assetic 方法

{% stylesheets
    '@SomeExampleBundle/Resources/views/ SOMEVAR /css/*'
%}
<link rel="stylesheet" href="{{ asset_url }}" />
{% endstylesheets %}

所以我想做的是从 Controller 传递 SOMEVAR

最佳答案

可以通过这种方式:

<link rel="stylesheet" href="{{ asset('bundles/yourbundle/css/'~ SOMEVAR ~'/css/' ) }}" />

关于php - 将变量传递给 Symfony2 中的 Assetic Assets URL,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8285562/

相关文章:

php - 使用php在数据库中存储点击次数

php - 没有MySQL可以在网站内搜索任何单词吗?

交响乐2 : filtering x-to-many relations

css - href Assets 不起作用

php - 上传文件时克服主机对 PHP/POST 数据的最大文件大小限制?

php - 在 php 中形成 mysql 查询

mysql - 在 Symfony 中打印 Sql 查询

html - 如何使用 Twig 中的 form_start 将没有值的属性应用于表单?

使用 asset_url 进行 Jquery UI Assets 管理

php - Symfony 3 - Assets 转储适用于开发但不适用于生产