Twig Dump没有打印任何内容 [英] Twig dump isn't printing anything

查看:113
本文介绍了Twig Dump没有打印任何内容的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我现在有点困惑.我一直像其他任何树枝功能一样使用树枝转储功能,但是现在它绝对没有输出.没有错误/异常,什么都没有. 其他一切都工作正常,例如反式过滤器.

I am a little bit confused right now. I always used the twig dump function like any other twig function but now it has absolutely no output. No errors/exceptions, just nothing. Everything else is working fine, like the trans filter.

{{ dump('test') }} # prints nothing
{{ 'layout.booking.chooseArea'|trans }} # prints the translated message

现在,此模板仅包含其他内容. 转储在父模板或base.html.twig中也不起作用.

Right now this template doesn't contain anything more than that. The dump also doesn't work in the parent template or in base.html.twig.

同样,转储什么也不打印:不是空字符串,不是null,也不是屏幕上的单个像素.

Again, the dump prints nothing: not an empty string, not null, not a single pixel on the screen.

有什么想法会导致这种情况吗?

Any ideas what could cause this?

Symfony版本:2.6.x-dev

Symfony version: 2.6.x-dev

更新

{{ dump('test') }} # doesn't work (anymore?)
{% dump('test') %} # does (still) work

此内容是否已删除?为什么没有错误?顺便说一下,调试标志已设置.

Has this been removed or something? Why are there no errors? By the way... debug flag is set.

推荐答案

在Symfony 2.6中,有一个新的VarDumper组件和DebugBundle.这些替代了twig的dump()函数,以提供更多更好的转储输出.

In Symfony 2.6, there is a new VarDumper component and DebugBundle. These override twig's dump() function to give a lot more and nicer dump output.

但是,您必须在AppKernel中注册DebugBundle,否则它将忽略该调用.为此,您应该将其添加到app/AppKernel.php:

However, you have to register the DebugBundle in your AppKernel, otherwise it'll just ignore the call. To do this, you should add this to app/AppKernel.php:

// app/AppKernel.php

// ...
public function registerBundles()
{
    // ...

    if (in_array($this->getEnvironment(), array('dev', 'test'))) {
        $bundles[] = new Symfony\Bundle\DebugBundle\DebugBundle();
        // ...
    }

    return $bundles;
}

请注意,此新的转储功能将在Web开发工具栏中转储输出,以避免搞乱页面布局.

Please note that this new dump function will dump the output in the web dev toolbar, to avoid screwing up the page layout.

在2.6.0中,可以通过回退本机树枝dump()函数(未注册DebugBundle的原因)来解决此问题.

In 2.6.0, this will be fixed by having a fallback to the native twig dump() function why the DebugBundle is not registered.

这篇关于Twig Dump没有打印任何内容的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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