From 4cd7287c6dccef9a4f24b821aed3621247b8a384 Mon Sep 17 00:00:00 2001 From: Sebastian Krebs Date: Tue, 4 Dec 2012 21:07:54 +0100 Subject: [PATCH] Added cookbook entry about FrameworkBundle:TemplateController --- cookbook/templating/index.rst | 1 + .../templating/render_without_controller.rst | 67 +++++++++++++++++++ 2 files changed, 68 insertions(+) create mode 100644 cookbook/templating/render_without_controller.rst diff --git a/cookbook/templating/index.rst b/cookbook/templating/index.rst index ec597f4d456..21ae6cda73c 100644 --- a/cookbook/templating/index.rst +++ b/cookbook/templating/index.rst @@ -7,3 +7,4 @@ Templating global_variables PHP twig_extension + render_without_controller diff --git a/cookbook/templating/render_without_controller.rst b/cookbook/templating/render_without_controller.rst new file mode 100644 index 00000000000..3217ac04a3e --- /dev/null +++ b/cookbook/templating/render_without_controller.rst @@ -0,0 +1,67 @@ +.. index:: + single: Templating; Render template without custom controller + +How to render a template without a custom controller +==================================================== + +This guide explains how to render a template within another template and +how to configure a page without a custom controller. + +The intention is, that there may be page in your application, that doesn't +need a controller, because there is no action associated with them. + +Rendering a template in twig: + +.. code-block:: jinja + + {% render "FrameworkBundle:Template:template" with {template: 'AcmeBundle::static.html.twig'} %} + +Directly routing to a template without custom controller with additional +caching parameters: + +.. configuration-block:: + + .. code-block:: yaml + + acme_static: + pattern: /static + defaults: + _controller: FrameworkBundle:Template:template + template: 'AcmeBundle::static.html.twig' + maxAge: 86400 + sharedMaxAge: 86400 + + .. code-block:: xml + + + + + + + FrameworkBundle:Template:template + AcmeBundle::static.html.twig + 86400 + 86400 + + + + .. code-block:: php + + use Symfony\Component\Routing\RouteCollection; + use Symfony\Component\Routing\Route; + + $collection = new RouteCollection(); + $collection->add('acme_static', new Route('/static', array( + '_controller' => 'FrameworkBundle:Template:template', + 'template' => 'Acmebundle::static.html.twig', + 'maxAge' => 86400, + 'sharedMaxAge' => 86400, + ))); + + return $collection; + +By default no caching headers were set. If you want to disable proxy +caching, but want to keep browser caching enabled, set ``private`` to +``false`` explictly.