diff --git a/src/RedefineMacro.php b/src/RedefineMacro.php index 3e852a8..f2f2b24 100644 --- a/src/RedefineMacro.php +++ b/src/RedefineMacro.php @@ -44,8 +44,16 @@ public function finalize() list($prolog) = parent::finalize(); - foreach ($compiler->getProperties()['blocks'] as $key => $val) { $blocks[$key] = $val; } - foreach ($compiler->getProperties()['blockTypes'] as $key => $val) { $blockTypes[$key] = $val; } + if (isset($compiler->getProperties()['blocks'])) { + foreach ($compiler->getProperties()['blocks'] as $key => $val) { + $blocks[$key] = $val; + } + } + if (isset($compiler->getProperties()['blockTypes'])) { + foreach ($compiler->getProperties()['blockTypes'] as $key => $val) { + $blockTypes[$key] = $val; + } + } $compiler->addProperty('blocks', $blocks); $compiler->addProperty('blockTypes', $blockTypes); diff --git a/tests/RedefineMacroTests.phpt b/tests/RedefineMacroTests.phpt index 26fcec3..de46f0a 100644 --- a/tests/RedefineMacroTests.phpt +++ b/tests/RedefineMacroTests.phpt @@ -27,3 +27,4 @@ Assert::same('import.latte', render('case1/main.latte')); Assert::same('main.latte', render('case2/main.latte')); Assert::same('import.latte', render('case3/main.latte')); Assert::same('import.latte', render('case4/main.latte')); +Assert::same('No blocks', render('case5/main.latte')); diff --git a/tests/case5/main.latte b/tests/case5/main.latte new file mode 100644 index 0000000..63546f5 --- /dev/null +++ b/tests/case5/main.latte @@ -0,0 +1 @@ +No blocks