[英]Why controller not render twig template
我在app/Resources/homepage 中有一个模板( homepage.html.twig )。 我正在尝试在HomeController
类中呈现此模板。
namespace AppBundle\Controller;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
class HomeController extends Controller
{
/**
* @Route("/home", name="homepage")
* @return \Symfony\Component\HttpFoundation\Response
*/
public function homeAction()
{
return $this->render('homepage/homepage.html.twig');
}
}
这是模板的内容。
{% extends 'base.html.twig' %}
{% block body %}
<div class="container">
<div class="jumbotron">
<h1>Navbar example</h1>
<p>This example is a quick exercise to illustrate how the default, static navbar and fixed to top navbar work. It includes the responsive CSS and HTML, so it also adapts to your viewport and device.</p>
<p>
<a class="btn btn-lg btn-primary" href=# role="button">View navbar docs »</a>
</p>
</div>
</div>
{% endblock %}
为什么渲染模板不起作用?
我通过放置解决了这个问题
{% block body %}
{% endblock %}
在 base.html.twig 中
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.