@@ -418,7 +418,7 @@ Rendering a Template in Services
418
418
Inject the ``twig `` Symfony service into your own services and use its
419
419
``render() `` method. When using :doc: `service autowiring </service_container/autowiring >`
420
420
you only need to add an argument in the service constructor and type-hint it with
421
- the :class: `Twig\E nvironment ` class::
421
+ the :class: `Twig\\ Environment ` class::
422
422
423
423
// src/Service/SomeService.php
424
424
use Twig\Environment;
@@ -643,7 +643,7 @@ following code to display the user information is repeated in several places:
643
643
644
644
{# ... #}
645
645
<div class="user-profile">
646
- <img src="{{ user.profileImageUrl }}" />
646
+ <img src="{{ user.profileImageUrl }}"/>
647
647
<p>{{ user.fullName }} - {{ user.email }}</p>
648
648
</div>
649
649
@@ -654,7 +654,7 @@ between full templates and template fragments).
654
654
Then, remove that content from the original ``blog/index.html.twig `` template
655
655
and add the following to include the template fragment:
656
656
657
- .. code-block :: html+ twig
657
+ .. code-block :: twig
658
658
659
659
{# templates/blog/index.html.twig #}
660
660
@@ -670,7 +670,7 @@ to rename variables. Imagine that your template stores the user information in a
670
670
variable called ``blog_post.author `` instead of the ``user `` variable that the
671
671
template fragment expects. Use the following to *rename * the variable:
672
672
673
- .. code-block :: html+ twig
673
+ .. code-block :: twig
674
674
675
675
{# templates/blog/index.html.twig #}
676
676
@@ -915,11 +915,11 @@ which have special meaning (e.g. replace ``<`` by the ``<`` HTML entity).
915
915
Symfony applications are safe by default because they perform automatic output
916
916
escaping thanks to the :ref: `Twig autoescape option <config-twig-autoescape >`:
917
917
918
- .. code-block :: twig
918
+ .. code-block :: html+ twig
919
919
920
- Hello {{ name }}
920
+ <p> Hello {{ name }}</p>
921
921
{# if 'name' is '<script>alert('hello!')</script>', Twig will output this:
922
- 'Hello <script>alert('hello!')</script>' #}
922
+ '<p> Hello <script>alert('hello!')</script></p> ' #}
923
923
924
924
If you are rendering a variable that is trusted and contains HTML contents,
925
925
use the `Twig raw filter `_ to disable the output escaping for that variable:
0 commit comments