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

Commit d060152

Browse files
committed
Merge branch 'hotfix/58'
Close #58 Fixes #57
2 parents bd3f729 + 6d19ba0 commit d060152

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
@@ -2,7 +2,7 @@
22

33
All notable changes to this project will be documented in this file, in reverse chronological order by release.
44

5-
## 2.0.1 - TBD
5+
## 2.0.1 - 2018-08-13
66

77
### Added
88

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

2323
### Fixed
2424

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

2728
## 2.0.0 - 2018-03-15
2829

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)