Skip to content

Commit 7299acc

Browse files
committed
minor #13264 Document RenderView method (Midwain)
This PR was merged into the 4.4 branch. Discussion ---------- Document RenderView method Hello! Current docs doesn't mention renderView() method (Symfony 4.+). <!-- If your pull request fixes a BUG, use the oldest maintained branch that contains the bug (see https://symfony.com/roadmap for the list of maintained branches). If your pull request documents a NEW FEATURE, use the same Symfony branch where the feature was introduced (and `master` for features of unreleased versions). --> Commits ------- 4ae1210 Document RenderView method
2 parents 14fc86c + 4ae1210 commit 7299acc

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

templates.rst

Lines changed: 13 additions & 0 deletions
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)