Skip to content

Commit 21178b1

Browse files
committed
[#2121] Tweaking a few things related to new render changes
1 parent 08a2847 commit 21178b1

File tree

4 files changed

+33
-15
lines changed

4 files changed

+33
-15
lines changed

book/http_cache.rst

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -906,12 +906,13 @@ writing the ESI tag yourself. That's because using a helper makes your
906906
application work even if there is no gateway cache installed.
907907

908908
When using the default ``render`` function (or setting the strategy to
909-
``default``), Symfony2 merges the included page content within the main one
910-
before sending the response to the client. But when using ``esi`` strategy,
911-
*and* if Symfony2 detects that it's talking to a gateway cache that supports
912-
ESI, it generates an ESI include tag. But if there is no gateway cache or if
913-
it does not support ESI, Symfony2 will just merge the included page content
914-
within the main one as it would have done if you had used ``render``.
909+
``default``), Symfony2 merges the included page content into the main one
910+
before sending the response to the client. But if you use the ``esi`` strategy
911+
(i.e. call ``render_esi``), *and* if Symfony2 detects that it's talking to
912+
a gateway cache that supports ESI, it generates an ESI include tag. But if
913+
there is no gateway cache or if it does not support ESI, Symfony2 will just
914+
merge the included page content within the main one as it would have done
915+
if you had used ``render``.
915916

916917
.. note::
917918

@@ -938,8 +939,8 @@ When using a controller reference, the ESI tag should reference the embedded
938939
action as an accessible URL so the gateway cache can fetch it independently of
939940
the rest of the page. Of course, an action can't be accessed via a URL unless
940941
it has a route that points to it. Symfony2 takes care of this via a generic
941-
route and controller. For the ESI include tag to work properly, you must
942-
define the ``_proxy`` route:
942+
route. For the ESI include tag to work properly, you must define the ``_proxy``
943+
route:
943944

944945
.. configuration-block::
945946

@@ -976,6 +977,12 @@ One great advantage of this caching strategy is that you can make your
976977
application as dynamic as needed and at the same time, hit the application as
977978
little as possible.
978979

980+
.. tip::
981+
982+
The proxy route doesn't point to a real controller. Instead, it's handled
983+
by an internal :class:`Symfony\\Component\\HttpKernel\\EventListener\\RouterProxyListener`
984+
class. This listener only responds to local IP addresses or trusted proxies.
985+
979986
.. note::
980987

981988
Once you start using ESI, remember to always use the ``s-maxage``

book/templating.rst

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -560,6 +560,10 @@ template using the ``with`` command.
560560
maps (i.e. an array with named keys). If you needed to pass in multiple
561561
elements, it would look like this: ``{'foo': foo, 'bar': bar}``.
562562

563+
.. versionadded:: 2.2
564+
The ``include()`` function is a new Twig feature that's available in
565+
Symfony 2.2. Prior, the ``{% include %}`` tag was used.
566+
563567
.. index::
564568
single: Templating; Embedding action
565569

@@ -715,10 +719,10 @@ in your application configuration:
715719
));
716720
717721
.. versionadded:: 2.2
718-
Default templates per render tag was added in Symfony 2.2
722+
Default templates per render function was added in Symfony 2.2
719723

720-
You can define default templates per ``render`` tag (which will override
721-
any global default templates that is defined):
724+
You can define default templates per ``render`` function (which will override
725+
any global default template that is defined):
722726

723727
.. configuration-block::
724728

quick_tour/the_view.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ some variable not available in the main template.
182182

183183
Suppose you've created a ``fancyAction`` controller method, and you want to
184184
"render" it inside the ``index`` template, which means including the result
185-
(e.g. ``HTML``) of the controller, use the ``render`` function:
185+
(e.g. ``HTML``) of the controller. To do this, use the ``render`` function:
186186

187187
.. code-block:: jinja
188188

reference/twig_reference.rst

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,21 +20,28 @@ Functions
2020
.. versionadded:: 2.1
2121
The ``csrf_token``, ``logout_path`` and ``logout_url`` functions were added in Symfony2.1
2222

23+
.. versionadded:: 2.3
24+
The ``render`` and ``controller`` functions are new in Symfony 2.2. Prior,
25+
the ``{% render %}`` tag was used and had a different signature.
26+
2327
+----------------------------------------------------+--------------------------------------------------------------------------------------------+
2428
| Function Syntax | Usage |
2529
+====================================================+============================================================================================+
26-
| ``render(controller('B:C:a', {params}))`` | This will render the Response Content for the given controller or |
27-
| ``render(path('route', {params}))`` | URL. For more information, see :ref:`templating-embedding-controller`. |
30+
| ``render(uri, options = {})`` | This will render the Response Content for the given controller or |
31+
| ``render(controller('B:C:a', {params}))`` | URL. For more information, see :ref:`templating-embedding-controller`. |
32+
| ``render(path('route', {params}))`` | |
2833
| ``render(url('route', {params}))`` | |
2934
+----------------------------------------------------+--------------------------------------------------------------------------------------------+
3035
| ``render_esi(controller('B:C:a', {params}))`` | This will generates an ESI tag when possible or fallback to the ``render`` |
3136
| ``render_esi(url('route', {params}))`` | behavior otherwise. For more information, see :ref:`templating-embedding-controller`. |
3237
| ``render_esi(path('route', {params}))`` | |
3338
+----------------------------------------------------+--------------------------------------------------------------------------------------------+
34-
| ``render_hinclude(controller('B:C:a', {params}))`` | This will generates an Hinclude tag for the given controller or URL. |
39+
| ``render_hinclude(controller(...))`` | This will generates an Hinclude tag for the given controller or URL. |
3540
| ``render_hinclude(url('route', {params}))`` | For more information, see :ref:`templating-embedding-controller`. |
3641
| ``render_hinclude(path('route', {params}))`` | |
3742
+----------------------------------------------------+--------------------------------------------------------------------------------------------+
43+
| ``controller(attributes = {}, query = {})`` | Used along with the ``render`` tag to refer to the controller that you want to render |
44+
+----------------------------------------------------+--------------------------------------------------------------------------------------------+
3845
| ``asset(path, packageName = null)`` | Get the public path of the asset, more information in |
3946
| | ":ref:`book-templating-assets`". |
4047
+----------------------------------------------------+--------------------------------------------------------------------------------------------+

0 commit comments

Comments
 (0)