Skip to content

Commit 4ae1210

Browse files
authored
Document RenderView method
1 parent df52e62 commit 4ae1210

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

templates.rst

+13
Original file line numberDiff line numberDiff line change
@@ -446,6 +446,19 @@ the :class:`Twig\\Environment` class::
446446
}
447447
}
448448

449+
Rendering a Template's Content
450+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
451+
The ``renderView()`` method renders a template and returns its content. The content from the template can be used to create a ``Response`` object::
452+
453+
use Symfony\Component\HttpFoundation\Response;
454+
455+
$content = $this->renderView('product/index.html.twig', [
456+
'category' => '...',
457+
'promotions' => ['...', '...'],
458+
);
459+
460+
return new Response($content);
461+
449462
Rendering a Template in Emails
450463
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
451464

0 commit comments

Comments
 (0)