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 #51327 [FrameworkBundle] Add AbstractController::renderBlock() and renderBlockView() (nicolas-grekas)
This PR was merged into the 6.4 branch.
Discussion
----------
[FrameworkBundle] Add `AbstractController::renderBlock()` and `renderBlockView()`
| Q | A
| ------------- | ---
| Branch? | 6.4
| Bug fix? | no
| New feature? | yes
| Deprecations? | no
| Tickets | -
| License | MIT
| Doc PR | -
This would be especially useful when generating turbo-stream responses.
Right now, [the doc](https://symfony.com/bundles/ux-turbo/current/index.html#coming-alive-with-turbo-streams) recommends creating new partial templates, but this increases the complexity and scatters HTML fragments. Instead, we could encourage using twig blocks.
Adding this could help remove some boilerplate.
before (using blocks):
```php
return new Response($this->container->get('twig')->load('foo.html.twig')->renderBlock('the_block', $context));
```
after:
```php
return $this->renderBlock('foo.html.twig', 'the_block', $context);
```
Commits
-------
fbf3814 [FrameworkBundle] Add `AbstractController::renderBlock()` and `renderBlockView()`
Copy file name to clipboardExpand all lines: src/Symfony/Bundle/FrameworkBundle/CHANGELOG.md
+1
Original file line number
Diff line number
Diff line change
@@ -4,6 +4,7 @@ CHANGELOG
4
4
6.4
5
5
---
6
6
7
+
* Add `AbstractController::renderBlock()` and `renderBlockView()`
7
8
* Add native return type to `Translator` and to `Application::reset()`
8
9
* Deprecate the integration of Doctrine annotations, either uninstall the `doctrine/annotations` package or disable the integration by setting `framework.annotations` to `false`
9
10
* Enable `json_decode_detailed_errors` context for Serializer by default if `kernel.debug` is true and the `seld/jsonlint` package is installed
thrownew \LogicException('You cannot use the "renderView" method if the Twig Bundle is not available. Try running "composer require symfony/twig-bundle".');
thrownew \LogicException(sprintf('You cannot use the "%s" method if the Twig Bundle is not available. Try running "composer require symfony/twig-bundle".', $method));
0 commit comments