-
-
Notifications
You must be signed in to change notification settings - Fork 384
Closed as not planned
Labels
Description
In the current implementation, the class for a Twig component is stored in /src/
directory, while its template is placed in /templates/components/
. This approach can become burdensome to manage the components.
./
├─ src/
│ ├─ TwigComponent/
│ │ ├─ AComponent.php
├─ templates/
│ ├─ components/
│ │ ├─ AComponent.html.twig
A simpler and clearer alternative is to keep the component template next to its class. For instance, in the class component definition:
#[AsTwigComponent(tpl: __DIR__.'/AComponent.html.twig')]
class AComponent{}
With this approach, the directory structure would look like:
./
├─ src/
│ ├─ TwigComponent/
│ │ ├─ AComponent.php
│ │ ├─ AComponent.html.twig
Alternatively, you could use a separate folder named _tpl
for templates:
#[AsTwigComponent(tpl: __DIR__.'/_tpl/AComponent.html.twig')]
class AComponent{}
With this setup, the directory structure would be:
./
├─ src/
│ ├─ TwigComponent/
│ │ ├─ _tpl/
│ │ │ ├─ AComponent.html.twig
│ │ ├─ AComponent.php