Symfony Twig模板AdminLTE不会渲染块

时间:2017-04-18 14:42:42

标签: symfony templates twig

我正在使用Almaseed AdminLTE avanzu捆绑包开发我的应用程序管理部分。如果我渲染整个页面,它的工作正常。

现在我开始划分为块并开始创建我的模板

我的模板分为

 - Admin
  - Template
     - header.html.twig
     - sidebar.html.twig
     - footer.html.twig
  - base.html.twig
  - index.html.twig

base.html.twig

<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <title>{% block title %}ADMIN{% endblock %}</title>
    <!-- Tell the browser to be responsive to screen width -->
    <meta content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" name="viewport">
    {% block stylesheets %}
        <!-- Bootstrap 3.3.6 -->
        <link rel="stylesheet" href="{{ asset('theme/bootstrap/css/bootstrap.min.css') }}">
        <!-- Font Awesome -->
        <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.5.0/css/font-awesome.min.css">
        <!-- Ionicons -->
        <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/ionicons/2.0.1/css/ionicons.min.css">
        <!-- Theme style -->
        <link rel="stylesheet" href="{{ asset('theme/dist/css/AdminLTE.min.css') }}">
        <!-- AdminLTE Skins -->
        <link rel="stylesheet" href="{{ asset('theme/dist/css/skins/skin-red.css') }}">
    {% endblock %}
    <!-- HTML5 Shim and Respond.js IE8 support of HTML5 elements and media queries -->
    <!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
    <!--[if lt IE 9]>
    <script src="https://oss.maxcdn.com/html5shiv/3.7.3/html5shiv.min.js"></script>
    <script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
    <![endif]-->
</head>

<body class="hold-transition skin-red sidebar-mini">
<div class="wrapper">

    {% block header %}
    {% endblock %}

    {% block sidebar %}
    {% endblock %}

    {% block body %}
    {% endblock %}

    {% block footer %}
    {% endblock %}

    {% block control %}
    {% endblock %}

</div>
<!-- ./wrapper -->

<!-- REQUIRED JS SCRIPTS -->
{% block javascripts %}
    <!-- jQuery 3.1.1 -->
    <script src="{{ asset('theme/plugins/jQuery/jquery-3.1.1.min.js') }}"></script>
    <!-- Bootstrap 3.3.6 -->
    <script src="{{  asset('theme/bootstrap/js/bootstrap.min.js') }}"></script>
    <!-- AdminLTE App -->
    <script src="{{ asset('theme/dist/js/adminlte.min.js') }}"></script>
    <!-- SlimScroll -->
    <script src="{{ asset('theme/plugins/slimScroll/jquery.slimscroll.js') }}"></script>
    <!-- FastClick -->
    <script src="{{ asset('theme/plugins/fastclick/fastclick.js') }}"></script>
{% endblock %}
</body>
</html>

header.html.twig

{% extends ':Admin/base.html.twig' %}
{% block header %}
<!-- Main Header -->
<header class="main-header">

    [[ ... ]]

</header>

{% endblock %}

sidebar.html.twig

{% extends 'Admin/base.html.twig' %}
{% block sidebar %}
<aside class="main-sidebar">

    <!-- sidebar: style can be found in sidebar.less -->
    <section class="sidebar">

       [[ ... ]]

    </section>
    <!-- /.sidebar -->
</aside>
{% endblock %}

index.html.twig

{% extends ':Admin:base.html.twig' %}

{% block title %}VedoCompro.it - ADMIN - Dashboard{% endblock %}

{% block body %}
    <!-- Content Wrapper. Contains page content -->
    <div class="content-wrapper">
        <!-- Content Header (Page header) -->
        <section class="content-header">

           [[ ... ]]

        </section>
        <!-- /.content -->
    </div>
    <!-- /.content-wrapper -->
{% endblock %}

行为

该网页仅使用index.html.twig中的所有资源呈现base.html.twig,但不会呈现header.html.twigsidebar.html.twigfooter.html.twig(我和#39;我在这里省略了)但在Profiler中我可以看到它已被加载:

Rendering Call Graph

main 1.67ms/100%
└ admin/index.html.twig
│ └ :Admin:base.html.twig
│   └ admin/index.html.twig::block(title)
│   └ :Admin:base.html.twig::block(stylesheets)
│   └ :Admin:base.html.twig::block(header)
│   └ :Admin:base.html.twig::block(sidebar)
│   └ admin/index.html.twig::block(body)
│   └ :Admin:base.html.twig::block(footer)
│   └ :Admin:base.html.twig::block(control)
│   └ :Admin:base.html.twig::block(javascripts)
└ @WebProfiler/Profiler/toolbar_js.html.twig 1.33ms/79%
  └ @WebProfiler/Profiler/base_js.html.twig

以下是可见的结果: behaviour

没有其他任何渲染,无法看到这个错误。如何使模板按预期调用基本文件中的块?

0 个答案:

没有答案