8000
We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
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
While trying to add Symfony 4 support to LiipThemeBundle I came across this: the bundle calls Symfony\Bundle\FrameworkBundle\Templating\Template\TemplateNameParser::parse() with a simple name (not containing a bundle): index.html. This creates a TemplateReference with no bundle, but TemplateReference::getPath() returns views/index.html.twig for the path. As with the twig engine the templates is searched in templates/ directory, this looks like a bug.
Symfony\Bundle\FrameworkBundle\Templating\Template\TemplateNameParser::parse()
index.html
TemplateReference
TemplateReference::getPath()
views/index.html.twig
templates/
The text was updated successfully, but these errors were encountered:
@yceruto would you mind checking this one please?
Sorry, something went wrong.
It looks like you're rendering a template that does not exists in Twig paths (run debug:twig to list the "Loader Paths") or it is loading like ::index.html.twig and as far as I can see (after Twig LoaderError) the templating BC layer rely on the kernel file_locator only, which just contains src/ and src/Resources/ paths, so if you have this template in src/Resources/views/ it works!
debug:twig
::index.html.twig
LoaderError
file_locator
src/
src/Resources/
src/Resources/views/
IMHO, nothing to do here ;) because the templating layer is absolete and it keep only BC with old structure.
I've created two Symfony 3.4 projects. In both of them I required the server package, so you can run ./bin/console server:run.
server
./bin/console server:run
In this project: https://github.com/geecu/sf34-twig I required the twig package, uncommented the routes in config/routes.yml, added a DefaultController with an index method that calls $this->render('index.html.twig'). This renders the template in __PROJECT_ROOT__/templates/index.html.twig.
twig
config/routes.yml
DefaultController
index
$this->render('index.html.twig')
__PROJECT_ROOT__/templates/index.html.twig
In this project: https://github.com/geecu/sf34-templating I required the templating package, uncommented the routes in config/routes.yml, and added
templating
framework: templating: engines: ['php']
This has a default controller that calls $this->render('index.php');. I was expecting this to work similar to the twig and render the file __PROJECT_ROOT__/templates/index.php.
$this->render('index.php');
__PROJECT_ROOT__/templates/index.php
But if you say it's kept only for BC and this is not to be expected, it's fine with me, I can close this issue.
While at it, I tried adding the src/Resources/views/index.php file. This renders the contents of that file, but it also throws:
src/Resources/views/index.php
The autoloader expected class "App\Resources\views\index" to be defined in file "__PROJECT__/vendor/composer/../../src/Resources/views/index.php". The file was found but the class was not in it, the class name or namespace probably has a typo.
Try renaming the template to src/Resources/views/index.html.php? and yeah, AFAIK symfony/templating component as template engine is obsolete.
src/Resources/views/index.html.php
symfony/templating
It works. Closing this issue as, per your mention, the templating component is obsolete. As far as I understand, the twig bridge doesn't work with the templating component, it has a separate implementation...
No branches or pull requests