File tree Expand file tree Collapse file tree 1 file changed +21
-0
lines changed Expand file tree Collapse file tree 1 file changed +21
-0
lines changed Original file line number Diff line number Diff line change @@ -632,6 +632,27 @@ 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
+
635
656
Rendering a Template in Services
636
657
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
637
658
You can’t perform that action at this time.
0 commit comments