简体   繁体   English

Symfony 4 - 不渲染树枝模板

[英]Symfony 4 - Not rendering Twig Template

When trying to render a Twig Template within a Symfony 4 project I'm getting an error. 当试图在Symfony 4项目中呈现Twig模板时,我收到一个错误。 I don't know which is the problem. 我不知道哪个是问题。 This is the code generating the error: 这是生成错误的代码:

return $this->render('templates/imagenes/index.html.twig');

And this is the error I'm getting: 这是我得到的错误:

LogicException You can not use the "render" method if the Templating Component or the Twig Bundle are not available. LogicException如果Templating Component或Twig Bundle不可用,则不能使用“render”方法。

Should I install Twig via composer apart Symfony itself? 我应该通过作曲家安装Twig Symfony吗?

谢谢@gogaz安装树枝做了伎俩。

composer require twig

你不应该需要模板目录,所以只需'imagenes / index.html.twig'

 return $this->render('templates/imagenes/index.html.twig');

Create the project using this command 使用此命令创建项目

composer create-project symfony/skeleton-website project_name

No need to install twig,etc 无需安装树枝等

A guy named Simon Wald-burger mentioned in the lesson's comments that installing "debug" fixed the issue (it fixed it for me). 一位名叫Simon Wald-burger的人在课程评论中提到安装“debug”修复了这个问题(它为我修好了)。 The instruction was in the next lesson. 该指令在下一课中。

composer require debug --dev

iiirxs is also correct, to output dump in twig file, do iiirxs也正确,在twig文件中输出dump,do

{{ dump(variable) }}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM