poirot/view

There is no license information available for the latest version (dev-devel) of this package.

Render View Templates.

Maintainers

Details

github.com/phPoirot/View

Source

Issues

Installs: 244

Dependents: 1

Suggesters: 0

Security: 0

Stars: 1

Watchers: 1

Forks: 0

pkg:composer/poirot/view

dev-devel 2019-05-26 11:06 UTC

This package is auto-updated.

Last update: 2025-09-27 01:27:36 UTC


README

Render Response Views

$view = new P\View\ViewModelTemplate([
    'resolver_options' => [
        '*' => __DIR__.'/templates'
    ],
]);
$bind = new P\View\ViewModelDecorateFeatures(clone $view);
$bind->setRenderer(\Poirot\View\renderManipulatedVars());
$bind->onNotifyRender = function($parentView, $self) {
    // Lookin for template_name.php beside base template
    /** @var P\View\ViewModelTemplate $self */
    $self->setExtension('php');
    $self->setTemplate($parentView->getTemplate());
    $self->setVariables($parentView->variables());
};
$bind->afterRender = function($result, $parent, $self) {
    if (is_array($result)) {
        /** @var P\View\ViewModelTemplate $parent */
        $parent->variables()->import($result);
    }
};

$view->bind($bind);

echo $view->setVariables(['user'=>'This is user'])->setTemplate('main')->render();