Skip to content

Commit a02daec

Browse files
committed
minor #309 Make adding a custom template more specific (htmlshaman1)
This PR was merged into the 2.x branch. Discussion ---------- Make adding a custom template more specific The docs are not wrong because #[AsTwigComponent('alert', 'my/custom/template.html.twig')] will indeed load the custom template. But if you are using multiple parameters: #[AsTwigComponent('alert', exposePublicProps:false, 'my/custom/template.html.twig')] Just adding a value for the template won't work. You need specify it's a template. The custom template works with the template parameter: #[AsTwigComponent('alert', exposePublicProps:false, template:'my/custom/template.html.twig')] | Q | A | ------------- | --- | Bug fix? | yes/no | New feature? | yes/no <!-- please update src/**/CHANGELOG.md files --> | Tickets | Fix #... <!-- prefix each issue number with "Fix #", no need to create an issue if none exist, explain below instead --> | License | MIT <!-- Replace this notice by a short README for your feature/bugfix. This will help people understand your PR and can be used as a start for the documentation. Additionally (see https://symfony.com/releases): - Always add tests and ensure they pass. - Never break backward compatibility (see https://symfony.com/bc). - Features and deprecations must be submitted against branch main. --> Commits ------- ba942fd Make adding a custom template more specific
2 parents 8010bef + ba942fd commit a02daec

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/TwigComponent/src/Resources/doc/index.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ as the second argument to the ``AsTwigComponent`` attribute:
184184
// ...
185185
186186
- #[AsTwigComponent('alert')]
187-
+ #[AsTwigComponent('alert', 'my/custom/template.html.twig')]
187+
+ #[AsTwigComponent('alert', template: 'my/custom/template.html.twig')]
188188
class AlertComponent
189189
{
190190
// ...

0 commit comments

Comments
 (0)