树枝延伸的树枝文件路径

Hab*_*wad 1 extends symfony twig

有两个twig文件src/MyVendor/MyBundle/Resources/views/MyApp/layout.html.twigsrc/MyVendor/MyBundle/Resources/views/MyApp/myView.html.twig.

的内容的src /的Myvendor/MyBundle /资源/视图/ MyApp的/ myView.html.twig

{% extends "layout.html.twig" %}
{% block content %}
   view content is here.
{% endblock %}
Run Code Online (Sandbox Code Playgroud)

但是我收到了一个错误

Unable to find template "layout.html.twig" in
"MyVendorMyBundle:MyApp:myView.html.twig"
Run Code Online (Sandbox Code Playgroud)

Vit*_*ian 7

你应该这样做:

{% extends "MyVendorMyBundle:MyApp:layout.html.twig" %}
Run Code Online (Sandbox Code Playgroud)

您可以在文档中找到更多详细信息

  • 他们隐藏了,他们真的隐瞒了这样一个事实,你必须从像'AcmeDemoBundle:欢迎:用户/ index.html.twig`这样的子文件扩展,请参阅http://stackoverflow.com/questions/13514643/including-the-twig -file-从-A-子目录 (3认同)