样式表和Symfony

巴罗希

有没有人可以向我解释样式表在Symfony中的工作方式?

根据文档,我应该使用以下代码:

{% block stylesheets %}
    {% stylesheets 'bundles/app/css/*' filter='cssrewrite' %}
        <link rel="stylesheet" href="{{ asset_url }}" />
    {% endstylesheets %}
{% endblock %}

因此,这是我的base.html.twig<head>标记的样子:

3 <head>
4     <meta charset="UTF-8" />
5     <title>{% block title %}Welcome!{% endblock %}</title>
6     {% block stylesheets %}
7         {% stylesheets 'bundles/app/css' filter='cssrewrite' %}
8             <link rel="stylesheet" type="text/css" href="" />
9         {% endstylesheets %}
10     {% endblock %}
11     <link rel="icon" type="image/x-icon" href="{{ asset('favicon.ico') }}" />
12 </head>

但是当我转到任何页面时,都会看到以下错误:

Unexpected "stylesheets" tag (expecting closing tag for the "block" tag defined near line 7) in base.html.twig at line 7.

提前致谢。

PawełMikołajczuk

首先,您需要手动安装和配置资产资产-因为默认情况下不再将其添加到Symfony(https://github.com/symfony/symfony-standard/pull/860)。

您拥有本食谱喜欢的所有信息。

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章