You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feature #2019 Adding convention to load Anonymous components from bundles (yceruto)
This PR was merged into the 2.x branch.
Discussion
----------
Adding convention to load Anonymous components from bundles
| Q | A
| ------------- | ---
| Bug fix? | no
| New feature? | yes
| Issues | Fix#2003 (partially)
| License | MIT
This adds a fallback convention to check if a requested anonymous component, `<twig:Acme:Alert>`, exists on the bundle side using the current Twig loading convention.
The resolution process would work like this:
* Currently, the finder will check if `components/Acme/Alert.html.twig` exists (resolving to `<app>/templates/components/Acme/Alert.html.twig`)
* If not, the finder will check if ``@Acme`/components/Alert.html.twig` exists (resolving to `<bundle>/templates/components/Alert.html.twig`) (this is the new code)
Here, the `components` directory is hardcoded for bundles, as `anonymous_template_directory` is exclusively a userland configuration.
```
acme-bundle/
└─ templates/
└─ components/
└─ Alert.html.twig
```
From here, you can organize your components into subdirectories if desired. For example, a component like `<twig:Acme:Table:Header>` will be located in `<acme-bundle>/templates/components/Table/Header.html.twig`.
TODO:
- [x] Add some tests
- [x] Add doc
Commits
-------
c207af6 Add Anonymous Components support for 3rd-party bundles
0 commit comments