Twig 小枝延伸不到';行不通

Twig 小枝延伸不到';行不通,twig,Twig,我第一次尝试设置一个新的细枝工作流 我目前正在使用xampp开发MacBookPro、El Capitan操作系统 我必须创建twig文件:base.twig和index.twig。我希望索引扩展基础,因此我的索引如下所示: {% extends 'base.twig' %} {% block header %} <p>hi</p> {% endblock %} {%extends'base.twig%} {%块头%} 嗨 {%endblock%} 这两个文

我第一次尝试设置一个新的细枝工作流

我目前正在使用xampp开发MacBookPro、El Capitan操作系统

我必须创建twig文件:base.twig和index.twig。我希望索引扩展基础,因此我的索引如下所示:

{% extends 'base.twig' %}

{% block header %}
    <p>hi</p>
{% endblock %}
{%extends'base.twig%}
{%块头%}
嗨

{%endblock%}
这两个文件都位于我的../app/Resources/views/文件夹中,但当我使用浏览器检查我的页面时,它只返回my base.twig的内容

这是我的基地。小枝:

<!doctype html>
<html lang="">
  <head>
    {% block head %}
      <meta charset="utf-8">
      <meta http-equiv="X-UA-Compatible" content="IE=edge">
      <meta name="description" content="">
      <meta name="viewport" content="width=device-width, initial-scale=1">
      <title>Web Project Template</title>
    {% endblock %}
  </head>
  <body>
    {# header #}
    <header class="header header__main">
      {% block header %}
      {% endblock %}
    </header>

    {# content #}
    <main class="content content__main">
      {% block content %}
      {% endblock %}
    </main>

    {# footer #}
    <footer class="footer footer__main">
      {{ include('../../app/Resources/views/partials/footer.twig') }}
    </footer>

  </body>
</html>

{%block head%}
Web项目模板
{%endblock%}
{#标题}
{%块头%}
{%endblock%}
{#内容}
{%block content%}
{%endblock%}
{#页脚}
{{include('../../app/Resources/views/partials/footer.twig')}
这是我的index.php,我在这里呈现模板:

<?php
require __DIR__.'/vendor/autoload.php';
/*
 * Go to this file in your web-browser to render Twig templates:
 *
 *  * http://localhost/index.php            -> index.twig
 *  * http://localhost/index.php/contact    -> contact.twig
 *
 * ... etc ...
 */
// 1) create a Symfony Request, used only to help make each URL render a different Twig template
use Symfony\Component\HttpFoundation\Request;
$request = Request::createFromGlobals();
$uri = $request->getPathInfo();
// 2) bootstrap Twig!
$loader = new Twig_Loader_Adapter(__DIR__.'/');
$twig = new Twig_Environment($loader, array(
    // cache disabled, since this is just a testing project
    'cache' => false,
    'debug' => true,
    'strict_variables' => true
));
$twig->addExtension(new Twig_Extension_Debug());
// 3) create a few different "pages"
switch ($uri) {
    // The Homepage! (/)
    case '/':
        echo $twig->render('../../app/Resources/views/base.twig', array(
            'pageTitle' => 'Suit Up!',
        ));
        break;
    // All other pages
    default:
        // if we have anything else, render the URL + .twig (e.g. /about -> about.twig)
        $template = substr($uri, 1).'.twig';
        echo $twig->render($template, array(
            'title' => 'Some random page!',
        ));
}

?>

您必须呈现文件
index.twig
。 Twig不会搜索扩展基础的其他文件

[...]
// The Homepage! (/)
    case '/':
        echo $twig->render('../../app/Resources/views/index.twig', array(
            'pageTitle' => 'Suit Up!',
        ));
        break;
[...]

你的基地里有头球吗?