From fc1af4b9b28d0ed5c1a7b7f851c75d74d8c117ba Mon Sep 17 00:00:00 2001 From: Tobias Naumann Date: Thu, 26 May 2011 11:14:15 +0200 Subject: [PATCH] Fixes default filter --- lib/Twig/Node/Expression/Filter.php | 1 + test/Twig/Tests/Fixtures/filters/default.test | 8 +++++++- 2 files changed, 8 insertions(+), 1 deletions(-) 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 -- 1.7.2.5