Skip to content
This repository has been archived by the owner on Aug 12, 2019. It is now read-only.

Commit

Permalink
Fix RedefineMacro when no blocks are defined
Browse files Browse the repository at this point in the history
  • Loading branch information
Jan Folwarczny committed Jul 6, 2016
1 parent 0b78f7c commit 38366b7
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 2 deletions.
12 changes: 10 additions & 2 deletions src/RedefineMacro.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
1 change: 1 addition & 0 deletions tests/RedefineMacroTests.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -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'));
1 change: 1 addition & 0 deletions tests/case5/main.latte
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
No blocks

0 comments on commit 38366b7

Please sign in to comment.