Skip to content

Commit 8899d34

Browse files
committed
Merge branch '5.0'
* 5.0: Reword Document RenderView method
2 parents 6a94a32 + fcbd5a0 commit 8899d34

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

templates.rst

+12
Original file line numberDiff line numberDiff line change
@@ -395,17 +395,29 @@ use the ``render()`` helper::
395395
namespace App\Controller;
396396

397397
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
398+
use Symfony\Component\HttpFoundation\Response;
398399

399400
class ProductController extends AbstractController
400401
{
401402
public function index()
402403
{
403404
// ...
404405

406+
// the `render()` method returns a `Response` object with the
407+
// contents created by the template
405408
return $this->render('product/index.html.twig', [
406409
'category' => '...',
407410
'promotions' => ['...', '...'],
408411
]);
412+
413+
// the `renderView()` method only returns the contents created by the
414+
// template, so you can use those contents later in a `Response` object
415+
$contents = $this->renderView('product/index.html.twig', [
416+
'category' => '...',
417+
'promotions' => ['...', '...'],
418+
]);
419+
420+
return new Response($contents);
409421
}
410422
}
411423

0 commit comments

Comments
 (0)