From: Tobias Naumann Date: Thu, 26 May 2011 09:14:15 +0000 (+0200) Subject: Fixes default filter X-Git-Url: http://git.silmor.de/gitweb/?a=commitdiff_plain;h=fc1af4b9b28d0ed5c1a7b7f851c75d74d8c117ba;p=web%2Fkonrad%2Ftwig.git Fixes default filter --- diff --git a/lib/Twig/Node/Expression/Filter.php b/lib/Twig/Node/Expression/Filter.php index 1979540..a1a97d1 100644 --- a/lib/Twig/Node/Expression/Filter.php +++ b/lib/Twig/Node/Expression/Filter.php @@ -40,6 +40,7 @@ class Twig_Node_Expression_Filter extends Twig_Node_Expression $compiler->subcompile($this->getNode('node')); } + $this->getNode('node')->removeAttribute('is_defined_test'); $compiler->raw(') ? ('); $this->compileFilter($compiler, $filter); $compiler->raw(') : ('); diff --git a/test/Twig/Tests/Fixtures/filters/default.test b/test/Twig/Tests/Fixtures/filters/default.test index dd3b998..04c11d1 100644 --- a/test/Twig/Tests/Fixtures/filters/default.test +++ b/test/Twig/Tests/Fixtures/filters/default.test @@ -3,14 +3,20 @@ --TEMPLATE-- {{ foo|default('bar') }} {{ bar|default('foo') }} +{{ baz.foo|default('bar') }} +{{ baz.bar|default('foo') }} {{ not_defined|default('bar') }} {{ 'a' ~ foo|default('b') }} +{{ 'a' ~ baz.foo|default('b') }} {{ 0|default('bar') }} --DATA-- -return array('foo' => null, 'bar' => 'bar') +return array('foo' => null, 'bar' => 'bar', 'baz' => array('foo' => null, 'bar' => 'bar')) --EXPECT-- bar bar bar +bar +bar +ab ab 0