Idea is to have view templates as classes, not as separate template files. It could be additional to commonly used pattern.
- A class can be a generator that may be helpful for HTTP chunked responses with huge pages.
- Each view class can require its own dependencies.
- No need to inject anything globally via config.
- No need to have vardoc at the beginning of each file.
- Each class can hold data and metadata.
- Syntax isn't good (need to verifiy that).
- Business logic in such class-views isn't as obvious evil as in view templates. People may get confused.
- Not sure how to deal with themes.
- Not sure how to deal with view translations.
Introduce TemplateInterface
with default implementation that uses template files:
$template = (new Template('filename', [data => data]));
$view->render($template);
Then there will be a way to implement another template transparently.
Addititional benefit:
Possible implementation