File tree Expand file tree Collapse file tree 1 file changed +25
-0
lines changed Expand file tree Collapse file tree 1 file changed +25
-0
lines changed Original file line number Diff line number Diff line change @@ -632,6 +632,31 @@ This might come handy when dealing with blocks in
632
632
:ref: `templates inheritance <template_inheritance-layouts >` or when using
633
633
`Turbo Streams `_.
634
634
635
+ Similarly, you can use the ``#[Template] `` attribute on the controller to specify a block
636
+ to render::
637
+
638
+ // src/Controller/ProductController.php
639
+ namespace App\Controller;
640
+
641
+ use Symfony\Bridge\Twig\Attribute\Template;
642
+ use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
643
+ use Symfony\Component\HttpFoundation\Response;
644
+
645
+ class ProductController extends AbstractController
646
+ {
647
+ #[Template('product.html.twig', block: 'price_block')]
648
+ public function price(): array
649
+ {
650
+ return [
651
+ // ...
652
+ ];
653
+ }
654
+ }
655
+
656
+ .. versionadded :: 7.2
657
+
658
+ The ``#[Template] `` attribute's ``block `` argument was introduced in Symfony 7.2.
659
+
635
660
Rendering a Template in Services
636
661
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
637
662
You can’t perform that action at this time.
0 commit comments