Symfony 4 - 不渲染 Twig 模板 [英] Symfony 4 - Not rendering Twig Template

查看:34
本文介绍了Symfony 4 - 不渲染 Twig 模板的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

尝试在 Symfony 4 项目中渲染 Twig 模板时出现错误.我不知道是哪个问题.这是产生错误的代码:

When trying to render a Twig Template within a Symfony 4 project I'm getting an error. I don't know which is the problem. This is the code generating the error:

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

这是我得到的错误:

逻辑异常如果模板组件或 Twig Bundle 不可用,则不能使用渲染"方法.

LogicException You can not use the "render" method if the Templating Component or the Twig Bundle are not available.

除了 Symfony 本身,我应该通过 composer 安装 Twig 吗?

Should I install Twig via composer apart Symfony itself?

推荐答案

感谢 @gogaz 安装 twig 解决了问题.

Thanks @gogaz Installing twig did the trick.

composer require twig

这篇关于Symfony 4 - 不渲染 Twig 模板的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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