Skip to content

Commit 025f02e

Browse files
committed
minor #4220 Added a note about the side effects of enabling both PHP and Twig (javiereguiluz)
This PR was merged into the 2.3 branch. Discussion ---------- Added a note about the side effects of enabling both PHP and Twig | Q | A | ------------- | --- | Doc fix? | no | New docs? | yes | Applies to | 2.3+ | Fixed tickets | #3293 Commits ------- fbbabb1 Reworded the explanation about the limitation of enablin PHP templates 5e47417 Improved the explanation thanks to @stof comments 3828162 Added a note about the side effects of enabling both PHP and Twig
2 parents 46fcb67 + fbbabb1 commit 025f02e

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

cookbook/templating/PHP.rst

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,33 @@ shortcut to render the default ``AcmeHelloBundle:Hello:index.html.php`` template
7777
return array('name' => $name);
7878
}
7979

80+
.. caution::
81+
82+
Enabling the ``php`` and ``twig`` template engines simultaneously is
83+
allowed, but it will produce an undesirable side effect in your application:
84+
the ``@`` notation for Twig namespaces will no longer be supported for the
85+
``render()`` method::
86+
87+
public function indexAction()
88+
{
89+
// ...
90+
91+
// namespaced templates will no longer work in controllers
92+
$this->render('@Acme/Default/index.html.twig');
93+
94+
// you must use the traditional template notation
95+
$this->render('AcmeBundle:Default:index.html.twig');
96+
}
97+
98+
.. code-block:: jinja
99+
100+
{# inside a Twig template, namespaced templates work as expected #}
101+
{{ include('@Acme/Default/index.html.twig') }}
102+
103+
{# traditional template notation will also work #}
104+
{{ include('AcmeBundle:Default:index.html.twig') }}
105+
106+
80107
.. index::
81108
single: Templating; Layout
82109
single: Layout

0 commit comments

Comments
 (0)