[英]Symfony2 Twig including header with assets not working
我正在嘗試將標頭包含在另一個模板中, 而不是這樣擴展
{% include '@Foo:Bar:_header.html.twig' %}
該標題包含
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="description" content="">
<meta name="author" content="">
<title>{{ site.name }}</title>
{% block stylesheets %}
{% stylesheets
"@Foo/Resources/public/app.css"
%}
<link rel="stylesheet" href="{{ asset_url }}" />
{% endstylesheets %}
{% endblock stylesheets %}
</head>
<body>
沒什么不尋常的,只是一些帶有資源的css文件。
這種行為使我拋出此異常
@@ Foo / bar / _header.html.twig中的模板編譯過程中引發了異常(“模板不支持“ bundle”參數。”)。
是吧?
如果不是將其包括{% include %}
而是將其擴展 {% extends %}
一切正常。
為什么我要包含而不是擴展? 我想創建新的塊,並包含其他內容等。
這個問題好嗎? 這是應該工作的方式嗎?
愚蠢的答案,愚蠢的問題。
修復程序正在從包含中刪除@
,我不知道為什么要使用它。
{% include '@Foo:Bar:_header.html.twig' %}
不起作用
{% include 'Foo:Bar:_header.html.twig' %}
工作
看到問題: https : //github.com/symfony/AsseticBundle/issues/331
它指出,要解決此問題,您應該將AsseticBundle更新為“ master-dev”分支(此問題已在幾天前得到修復,但尚未在穩定的Bundle版本中合並)
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.