Skip to content

Document RenderView method #13264

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 23, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions templates.rst
Original file line number Diff line number Diff line change
Expand Up @@ -446,6 +446,19 @@ the :class:`Twig\\Environment` class::
}
}

Rendering a Template's Content
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
The ``renderView()`` method renders a template and returns its content. The content from the template can be used to create a ``Response`` object::
Copy link
Contributor

@94noni 94noni Feb 27, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

new line i think here
and also, new line after the its content.


use Symfony\Component\HttpFoundation\Response;

$content = $this->renderView('product/index.html.twig', [
'category' => '...',
'promotions' => ['...', '...'],
);

return new Response($content);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice idea 👍
i would for example call a specific $response->aMethod() so that readers understand the idea behind getting the view like that and play with the $response before returning it


Rendering a Template in Emails
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Expand Down