Friday, July 22, 2016

Symfony3 Render

Rendering Templates

If you're serving HTML, you'll want to render a template. The render() method renders a templateand puts that content into a Response object for you:
// renders app/Resources/views/hello/index.html.twig
return $this->render('hello/index.html.twig', array('name' => $name));
Templates can also live in deeper sub-directories. Just try to avoid creating unnecessarily deep structures:
// renders app/Resources/views/hello/greetings/index.html.twig
return $this->render('hello/greetings/index.html.twig', array(
    'name' => $name
));

No comments: