Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Initial PR for POC in Move to a Twig Loader concept #278 #280

Open
wants to merge 1 commit into
base: v3
Choose a base branch
from

Conversation

gabrielsolomon
Copy link

No description provided.

$this->engine->getResolveTemplatePath()->prependPath($this->vfsPath('templates/child'));

$this->when_the_engine_renders('main');
$this->then_the_rendered_template_matches('<html>child: parent</html>');
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This example looks just like what's possible with the Theme support, can you highlight how this is different in a test case?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants