得到扩展的模板不能有正文的错误 [英] getting error that a template that extends can not have body

查看:21
本文介绍了得到扩展的模板不能有正文的错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在编写 jobeet 教程.当我像这样在本地主机上运行项目时:

I am working on jobeet tutorial. When I am running the project on localhost like this:

http://localhost/Symfony/web/app_dev.php/ens_job/

我收到一个错误

A template that extends another one cannot have a body in EnslJobeetBundle:Job:index.html.twig at line 7.

这种情况我该怎么办?

我使用 index.html.twig 如下:

I am using the index.html.twig as follow:

<!-- src/Ens/JobeetBundle/Resources/views/Job/index.html.twig -->
{% extends 'EnsJobeetBundle::layout.html.twig' %}

{% block stylesheets %}
  {{ parent() }}
  <link rel="stylesheet" href="{{ asset('bundles/ensjobeet/css/jobs.css') }}" type="text/css" media="all" />
{% endblock %}

<!-- the rest of the code -->

推荐答案

当您的内容超出子模板中的 blocks 时,会发生此错误.

This error occurs when you have content out of blocks in child template.

您必须从 index.html.twig 中删除 <!-- src/Ensl/JobeetBundle/Resources/views/Job/index.html.twig -->

这篇关于得到扩展的模板不能有正文的错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆