Closed
Description
UX Twig Component version
2.12
Description
When i define a custom twig template of a component, it's ok where I called the component with the classic syntax but it's not possible to find the template with the new twig:component syntax.
How to reproduce
composer req symfony/ux-twig-component
(Version v2.12.0)
1- Configure a new folder for Twig
# config/packages/twig.yaml
twig:
paths:
- '%kernel.project_dir%/templates'
- '%kernel.project_dir%/components'
2- Configure PHP classes autoload (❗dump-autoload)
"autoload": {
"psr-4": {
"App\\": "src/",
"Component\\": "components/"
}
},
and
services:
Component\:
resource: '../components/'
3- Create a folder components/Button
4- Create a PHP file
<?php
namespace Component\Button;
use Symfony\UX\TwigComponent\Attribute\AsTwigComponent;
#[AsTwigComponent('button', template: 'button.twig')]
class ButtonComponent { }
5- Create a Twig file components/button.twig
<button>Wixiweb</button>
You can use this button like this :
{{ component('button') }}
But you cannot use this button like this :
<twig:button></twig:button>
Unable to find template "button.twig" (looked into: /templates, /components, /templates) in [home/index.twig at line 13]
From : symfony/symfony#52154