zendframework / zend-expressive-zendviewrenderer

zend-view PhpRenderer integration for Expressive
BSD 3-Clause "New" or "Revised" License
11 stars 12 forks source link

Default parameters not passed to child view models #57

Closed samuelnogueira closed 6 years ago

samuelnogueira commented 6 years ago

I'm trying to set default params for child templates.

Code to reproduce the issue

use Zend\Expressive\Template\TemplateRendererInterface;
use Zend\View\Model\ViewModel;

/** @var \Zend\Expressive\ZendView\ZendViewRenderer $renderer */
$renderer->addDefaultParam(TemplateRendererInterface::TEMPLATE_ALL, 'user', 'john.doe');

echo $renderer->render(
    'my-view',
    (new ViewModel)->addChild(
        (new ViewModel)->setTemplate('my-sub-view'),
        'sub'
    )
);

// assume 'my-view' template to be: '<?php echo $this->sub;'
// assume 'my-sub-view' template to be: '<?php echo $this->user;'

Expected results

john.doe string echoed

Actual results

null/empty string echoed