Closed raffaelj closed 1 year ago
The viewvars
property was removed for a reason. The render method should be state- or contextless.
If you've a need for a global var storage I recommend to register an object that works as a storage.
The multi inheritance also adds additional complexity with possible edge cases also with the passed slots.
Thank you for your contribution but I have to put it on hold for now until I see a real gain for the project.
I did some research about template engines recently and I agree, that layout inheritance is error-prone. I still miss the @render('views:partials/file.php')
functionality from Lexy
in v1.
When I need a more powerful template engine, I'll pass my custom logic to Lexy or Twig and bypass the whole $app->render()
method.
Allow layout inheritance, e. g.:
page.php
has layoutdefault.php
post.php
has layoutblog.php
, which itself has layoutdefault.php
Alternative syntax:
$this->render('views:page.php with layouts:default.php')
$this->render('views:post.php with layouts:blog.php with layouts:default.php')
I also added
$viewVars
, which were dropped during the rewrite from v1 to v2.The slots, that are passed to the initial call of
render($view, $slots)
, are available in all parent/stacked layouts.I added some more context in the discussion of #135.
Closes #135.