继承布局中块外的 HTML


HTML outside of block in inheriting layout

如果我错了,请纠正我,但不可能在继承布局的块之外使用 html 代码,对吧?

这就是我的意思

{# app/Resources/view/base.html.twig #}
<!DOCTYPE html>
......
<% block sidebar %>
<h1>...</h1>
<% endblock; %>
{# src/Acme/CoolBundle/Controller/page.html.twig #}
{% extends '::base.html.twig' %}
{% block sidebar %}
 {{ parent{} }}
 <p>Lorem ipsum bla bla.. </p> // This one  works and the paragraph is rendered
{% endblock }
<h3>Latest news</h3> // Here I get A template that extends another one cannot have a body in...

你是对的(这次;))。不可能将 html 外部块放在扩展其他块的模板中。