Initial PR for POC in Move to a Twig Loader concept #278#280
Initial PR for POC in Move to a Twig Loader concept #278#280gabrielsolomon wants to merge 1 commit intothephpleague:v3from
Conversation
| $this->engine->getResolveTemplatePath()->prependPath($this->vfsPath('templates/child')); | ||
|
|
||
| $this->when_the_engine_renders('main'); | ||
| $this->then_the_rendered_template_matches('<html>child: parent</html>'); |
There was a problem hiding this comment.
This example looks just like what's possible with the Theme support, can you highlight how this is different in a test case?
There was a problem hiding this comment.
The advantages i see for this approach are:
You have the possibility of themes by default
Just add a new path and you have a theme, no need for separate classes.
You could have so that for each namespace you have different templates
You could do
$resolver->addPath('templates/base');
$resolver->addPath('templates/theme1');
$resolver->addPath('templates/admin-base', 'Adminer');
$resolver->addPath('templates/admin-theme1', 'Adminer');In this way you could overwrite for namespace Adminer in folder theme1 just the templates that were different.
All the logic for template resolve is one file
Not spread across the classes Name, Engine, Folders etc.
The user can create custom loading just in one place, maybe a caching system for example.
There was a problem hiding this comment.
Hi,
I understand about exemple of @gabrielsolomon, using Theme and folder functionnality like this :
`// Create new Plates engine
$templates = new League\Plates\Engine('templates/base');
// Add Theme
$templates->addPath('templates/theme1');
//Add "folder" (=namespace) Adminer
$templates->addPath('templates/admin-base', 'Adminer');
//A theme for adminer
$templates->addPath('templates/admin-theme1', 'Adminer');
// Create a new template
$template = $templates->make('Adminer::welcome');
`
If is that, i love this syntax. She's simple and mode easy to use than initial theme proposal. And we can easy use folder/namespace with theme.
3.5 is not realised, is-it possible to switch to this PR before 3.5 release ?
No description provided.