Skip to content
This repository was archived by the owner on Jan 21, 2020. It is now read-only.

Commit ed3edaf

Browse files
committed
Merge branch 'hotfix/58' into develop
Forward port #58 Conflicts: CHANGELOG.md
2 parents 0ad9fce + 6d19ba0 commit ed3edaf

File tree

3 files changed

+29
-2
lines changed

3 files changed

+29
-2
lines changed

CHANGELOG.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ All notable changes to this project will be documented in this file, in reverse
2424

2525
- Nothing.
2626

27-
## 2.0.1 - TBD
27+
## 2.0.1 - 2018-08-13
2828

2929
### Added
3030

@@ -44,7 +44,8 @@ All notable changes to this project will be documented in this file, in reverse
4444

4545
### Fixed
4646

47-
- Nothing.
47+
- [#58](https://github.com/zendframework/zend-expressive-zendviewrenderer/pull/58) fixes an issue whereby the default renderer parameters were not
48+
- being merged into the view model passed to the renderer. It now correctly does so.
4849

4950
## 2.0.0 - 2018-03-15
5051

src/ZendViewRenderer.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,7 @@ private function renderModel(ModelInterface $model, RendererInterface $renderer)
205205
continue;
206206
}
207207

208+
$child = $this->mergeViewModel($child->getTemplate(), $child);
208209
$result = $this->renderModel($child, $renderer);
209210

210211
if ($child->isAppend()) {

test/ZendViewRendererTest.php

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -581,4 +581,29 @@ public function testCanRenderWithChildViewModel()
581581

582582
$this->assertEquals($content, $result);
583583
}
584+
585+
public function testRenderChildWithDefaultParameter()
586+
{
587+
$name2 = 'Foo';
588+
589+
$renderer = new ZendViewRenderer();
590+
$renderer->addPath(__DIR__ . '/TestAsset');
591+
$renderer->addDefaultParam('zendview-2', 'name', $name2);
592+
593+
$viewModelChild = new ViewModel();
594+
$viewModelChild->setTemplate('zendview-2');
595+
596+
$viewModelParent = new ViewModel();
597+
$viewModelParent->addChild($viewModelChild, 'name');
598+
599+
$result = $renderer->render('zendview', $viewModelParent);
600+
601+
$contentChild = file_get_contents(__DIR__ . '/TestAsset/zendview-2.phtml');
602+
$contentChild = str_replace('<?php echo $name ?>', $name2, $contentChild);
603+
604+
$content = file_get_contents(__DIR__ . '/TestAsset/zendview.phtml');
605+
$content = str_replace('<?php echo $name ?>', $contentChild, $content);
606+
607+
static::assertEquals($content, $result);
608+
}
584609
}

0 commit comments

Comments
 (0)