我在base.html.twig中有这部分代码:
{% stylesheets 'bundles/study/css/*' filter='cssrewrite' %}
<link rel="stylesheet" href="{{ asset('bundles/study/css/style.css') }}" />
<link rel="stylesheet" href="{{ asset('bundles/study/css/boilerplate.css') }}">
<link rel="stylesheet" href="{{ asset('bundles/study/css/jquery-ui.min.css')}}">
<link rel="stylesheet" href="{{ asset('bundles/study/css/jquery-ui.structure.min.css')}}">
<link rel="stylesheet" href="{{ asset('bundles/study/css/jquery-ui.theme.min.css')}}">
{% endstylesheets %}
网页代码中的Symfony2 / Twig生成:
<link href="/bundles/study/css/style.css" rel="stylesheet">
<link href="/bundles/study/css/boilerplate.css" rel="stylesheet">
<link href="/bundles/study/css/jquery-ui.min.css" rel="stylesheet">
<link href="/bundles/study/css/jquery-ui.structure.min.css" rel="stylesheet">
<link href="/bundles/study/css/jquery-ui.theme.min.css" rel="stylesheet">
<link href="/bundles/study/css/style.css" rel="stylesheet">
<link href="/bundles/study/css/boilerplate.css" rel="stylesheet">
<link href="/bundles/study/css/jquery-ui.min.css" rel="stylesheet">
<link href="/bundles/study/css/jquery-ui.structure.min.css" rel="stylesheet">
<link href="/bundles/study/css/jquery-ui.theme.min.css" rel="stylesheet">
<link href="/bundles/study/css/style.css" rel="stylesheet">
<link href="/bundles/study/css/boilerplate.css" rel="stylesheet">
<link href="/bundles/study/css/jquery-ui.min.css" rel="stylesheet">
<link href="/bundles/study/css/jquery-ui.structure.min.css" rel="stylesheet">
<link href="/bundles/study/css/jquery-ui.theme.min.css" rel="stylesheet">
<link href="/bundles/study/css/style.css" rel="stylesheet">
<link href="/bundles/study/css/boilerplate.css" rel="stylesheet">
<link href="/bundles/study/css/jquery-ui.min.css" rel="stylesheet">
<link href="/bundles/study/css/jquery-ui.structure.min.css" rel="stylesheet">
<link href="/bundles/study/css/jquery-ui.theme.min.css" rel="stylesheet">
<link href="/bundles/study/css/style.css" rel="stylesheet">
<link href="/bundles/study/css/boilerplate.css" rel="stylesheet">
<link href="/bundles/study/css/jquery-ui.min.css" rel="stylesheet">
<link href="/bundles/study/css/jquery-ui.structure.min.css" rel="stylesheet">
<link href="/bundles/study/css/jquery-ui.theme.min.css" rel="stylesheet">
<link href="/bundles/study/css/style.css" rel="stylesheet">
<link href="/bundles/study/css/boilerplate.css" rel="stylesheet">
<link href="/bundles/study/css/jquery-ui.min.css" rel="stylesheet">
<link href="/bundles/study/css/jquery-ui.structure.min.css" rel="stylesheet">
<link href="/bundles/study/css/jquery-ui.theme.min.css" rel="stylesheet">
为什么Twig会对同一个链接产生6次调用?
如果我退出
,我可以提供有关代码的任何信息&#39; {%stylesheets&#39; bundles / study / css / *&#39;滤波器=&#39; cssrewrite&#39; %}&#39;和&#39; {%endstylesheets%}&#39;
所有工作正常(我认为),但我需要理解为什么Twig创建相同行的6倍
答案 0 :(得分:3)
键入时:
{% stylesheets 'bundles/study/css/*' filter='cssrewrite' %}
告诉Twig在bundles/study/css
中包含所有(*)文件。
对于找到的每个文件,您将获得stylesheets
和endstylesheets
之间的内容,因此基本上,如果您有6个文件,则您将有6次内容...