Mar*_*der 3 symfony twig symfony-2.6 twig-extension
我现在有点困惑.我总是使用twig dump函数像任何其他twig函数,但现在它绝对没有输出.没有错误/异常,只是没有.其他一切工作正常,如反式过滤器.
{{ dump('test') }} # prints nothing
{{ 'layout.booking.chooseArea'|trans }} # prints the translated message
Run Code Online (Sandbox Code Playgroud)
现在这个模板不包含任何东西.转储在父模板或base.html.twig中也不起作用.
同样,转储什么都不打印:不是空字符串,不是空,而不是屏幕上的单个像素.
有什么想法会导致这种情况吗?
Symfony版本:2.6.x-dev
更新
{{ dump('test') }} # doesn't work (anymore?)
{% dump('test') %} # does (still) work
Run Code Online (Sandbox Code Playgroud)
这已被删除或什么?为什么没有错误?顺便说一句...设置调试标志.
在Symfony 2.6中,有一个新的VarDumper组件和DebugBundle.这些覆盖了twig的dump()功能,可以提供更多更好的转储输出.
但是,您必须在您的注册DebugBundle AppKernel,否则它将忽略该调用.为此,您应该将其添加到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;
}
Run Code Online (Sandbox Code Playgroud)
请注意,这个新的转储功能会将输出转储到Web开发工具栏中,以避免搞砸页面布局.
在2.6.0中,这将通过回退本机
dump()twig函数来解决,为什么DebugBundle没有注册.
| 归档时间: |
|
| 查看次数: |
1226 次 |
| 最近记录: |