Skip to content

Commit c447053

Browse files
committed
minor #5859 Use Twig highlighter instead of Jinja (WouterJ)
This PR was merged into the 2.3 branch. Discussion ---------- Use Twig highlighter instead of Jinja Pygments 2 supports the Twig highlighting language, which is (of course) closer to Twig than Jinja is. Previously, we reverted one occurence of Twig in #5378 , because people might use older versions locally. I no longer think this is a good reason: * They can update the versions, Pygments 2 isn't that new * Now we have platform.sh and travis, building locally isn't recommended/required anymore (if it ever was) | Q | A | --- | --- | Doc fix? | yes | New docs? | no | Applies to | 2.3+ | Fixed ticket | - This requires fabpot/sphinx-php#31 to be merged first. (and Pygments 2 to be available on symfony.com's server, but I think it already is /cc @javiereguiluz ) Commits ------- d116232 Fix formatting 57c2d4b Use Twig highlighter instead of Jinja
2 parents 00b2b85 + d116232 commit c447053

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

57 files changed

+235
-235
lines changed

best_practices/configuration.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ from places with access to the Symfony container.
128128
Constants can be used for example in your Twig templates thanks to the
129129
`constant() function`_:
130130

131-
.. code-block:: html+jinja
131+
.. code-block:: html+twig
132132

133133
<p>
134134
Displaying the {{ constant('NUM_ITEMS', post) }} most recent results.

best_practices/forms.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ This is also an important error, because you are mixing presentation markup
137137
always a good practice to follow, so put all the view-related things in the
138138
view layer:
139139

140-
.. code-block:: html+jinja
140+
.. code-block:: html+twig
141141

142142
{{ form_start(form) }}
143143
{{ form_widget(form) }}
@@ -157,7 +157,7 @@ One of the simplest ways - which is especially useful during development -
157157
is to render the form tags and use ``form_widget()`` to render all of the
158158
fields:
159159

160-
.. code-block:: html+jinja
160+
.. code-block:: html+twig
161161

162162
{{ form_start(form, {'attr': {'class': 'my-form-class'} }) }}
163163
{{ form_widget(form) }}

best_practices/web-assets.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ the application assets are in one location.
1616
Templates also benefit from centralizing your assets, because the links are
1717
much more concise:
1818

19-
.. code-block:: html+jinja
19+
.. code-block:: html+twig
2020

2121
<link rel="stylesheet" href="{{ asset('css/bootstrap.min.css') }}" />
2222
<link rel="stylesheet" href="{{ asset('css/main.css') }}" />
@@ -54,7 +54,7 @@ of compiling assets developed with a lot of different frontend technologies
5454
like LESS, Sass and CoffeeScript. Combining all your assets with Assetic is a
5555
matter of wrapping all the assets with a single Twig tag:
5656

57-
.. code-block:: html+jinja
57+
.. code-block:: html+twig
5858

5959
{% stylesheets
6060
'css/bootstrap.min.css'

book/controller.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -642,7 +642,7 @@ read any flash messages from the session::
642642

643643
.. configuration-block::
644644

645-
.. code-block:: html+jinja
645+
.. code-block:: html+twig
646646

647647
{% for flash_message in app.session.flashbag.get('notice') %}
648648
<div class="flash-notice">

book/forms.rst

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ helper functions:
142142

143143
.. configuration-block::
144144

145-
.. code-block:: html+jinja
145+
.. code-block:: html+twig
146146

147147
{# app/Resources/views/default/new.html.twig #}
148148
{{ form_start(form) }}
@@ -450,7 +450,7 @@ corresponding errors printed out with the form.
450450

451451
.. configuration-block::
452452

453-
.. code-block:: html+jinja
453+
.. code-block:: html+twig
454454

455455
{# app/Resources/views/default/new.html.twig #}
456456
{{ form(form, {'attr': {'novalidate': 'novalidate'}}) }}
@@ -794,7 +794,7 @@ of code. Of course, you'll usually need much more flexibility when rendering:
794794

795795
.. configuration-block::
796796

797-
.. code-block:: html+jinja
797+
.. code-block:: html+twig
798798

799799
{# app/Resources/views/default/new.html.twig #}
800800
{{ form_start(form) }}
@@ -836,7 +836,7 @@ output can be customized on many different levels.
836836

837837
.. configuration-block::
838838

839-
.. code-block:: jinja
839+
.. code-block:: twig
840840
841841
{{ form.vars.value.task }}
842842
@@ -858,7 +858,7 @@ used the ``form_row`` helper:
858858

859859
.. configuration-block::
860860

861-
.. code-block:: html+jinja
861+
.. code-block:: html+twig
862862

863863
{{ form_start(form) }}
864864
{{ form_errors(form) }}
@@ -910,7 +910,7 @@ specify it:
910910

911911
.. configuration-block::
912912

913-
.. code-block:: html+jinja
913+
.. code-block:: html+twig
914914

915915
{{ form_label(form.task, 'Task Description') }}
916916

@@ -926,7 +926,7 @@ field:
926926

927927
.. configuration-block::
928928

929-
.. code-block:: html+jinja
929+
.. code-block:: html+twig
930930

931931
{{ form_widget(form.task, {'attr': {'class': 'task_field'}}) }}
932932

@@ -942,7 +942,7 @@ to get the ``id``:
942942

943943
.. configuration-block::
944944

945-
.. code-block:: html+jinja
945+
.. code-block:: html+twig
946946

947947
{{ form.task.vars.id }}
948948

@@ -955,7 +955,7 @@ the ``full_name`` value:
955955

956956
.. configuration-block::
957957

958-
.. code-block:: html+jinja
958+
.. code-block:: html+twig
959959

960960
{{ form.task.vars.full_name }}
961961

@@ -1012,7 +1012,7 @@ to the ``form()`` or the ``form_start()`` helper:
10121012

10131013
.. configuration-block::
10141014

1015-
.. code-block:: html+jinja
1015+
.. code-block:: html+twig
10161016

10171017
{# app/Resources/views/default/new.html.twig #}
10181018
{{ form_start(form, {'action': path('target_route'), 'method': 'GET'}) }}
@@ -1386,7 +1386,7 @@ Render the ``Category`` fields in the same way as the original ``Task`` fields:
13861386

13871387
.. configuration-block::
13881388

1389-
.. code-block:: html+jinja
1389+
.. code-block:: html+twig
13901390

13911391
{# ... #}
13921392

@@ -1455,7 +1455,7 @@ do this, create a new template file that will store the new markup:
14551455

14561456
.. configuration-block::
14571457

1458-
.. code-block:: html+jinja
1458+
.. code-block:: html+twig
14591459

14601460
{# app/Resources/views/form/fields.html.twig #}
14611461
{% block form_row %}
@@ -1484,7 +1484,7 @@ renders the form:
14841484

14851485
.. configuration-block::
14861486

1487-
.. code-block:: html+jinja
1487+
.. code-block:: html+twig
14881488

14891489
{# app/Resources/views/default/new.html.twig #}
14901490
{% form_theme form 'form/fields.html.twig' %}
@@ -1673,7 +1673,7 @@ to define form output.
16731673
In Twig, you can also customize a form block right inside the template
16741674
where that customization is needed:
16751675

1676-
.. code-block:: html+jinja
1676+
.. code-block:: html+twig
16771677

16781678
{% extends 'base.html.twig' %}
16791679

book/from_flat_php_to_symfony2.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -710,7 +710,7 @@ called `Twig`_ that makes templates faster to write and easier to read.
710710
It means that the sample application could contain even less code! Take,
711711
for example, the list template written in Twig:
712712

713-
.. code-block:: html+jinja
713+
.. code-block:: html+twig
714714

715715
{# app/Resources/views/blog/list.html.twig #}
716716
{% extends "layout.html.twig" %}
@@ -732,7 +732,7 @@ for example, the list template written in Twig:
732732

733733
The corresponding ``layout.html.twig`` template is also easier to write:
734734

735-
.. code-block:: html+jinja
735+
.. code-block:: html+twig
736736

737737
{# app/Resources/views/layout.html.twig #}
738738
<!DOCTYPE html>

book/http_cache.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1073,7 +1073,7 @@ matter), Symfony uses the standard ``render`` helper to configure ESI tags:
10731073

10741074
.. configuration-block::
10751075

1076-
.. code-block:: jinja
1076+
.. code-block:: twig
10771077
10781078
{# app/Resources/views/static/about.html.twig #}
10791079

book/page_creation.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -374,7 +374,7 @@ a ``number.html.twig`` file inside of it:
374374

375375
.. configuration-block::
376376

377-
.. code-block:: jinja
377+
.. code-block:: twig
378378
379379
{# app/Resources/views/lucky/number.html.twig #}
380380
{% extends 'base.html.twig' %}

book/routing.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1458,7 +1458,7 @@ a template helper function:
14581458

14591459
.. configuration-block::
14601460

1461-
.. code-block:: html+jinja
1461+
.. code-block:: html+twig
14621462

14631463
<a href="{{ path('blog_show', {'slug': 'my-blog-post'}) }}">
14641464
Read this blog post.
@@ -1491,7 +1491,7 @@ to ``generate()``:
14911491

14921492
.. configuration-block::
14931493

1494-
.. code-block:: html+jinja
1494+
.. code-block:: html+twig
14951495

14961496
<a href="{{ url('blog_show', {'slug': 'my-blog-post'}) }}">
14971497
Read this blog post.

book/security.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -846,7 +846,7 @@ the built-in helper function:
846846

847847
.. configuration-block::
848848

849-
.. code-block:: html+jinja
849+
.. code-block:: html+twig
850850

851851
{% if is_granted('ROLE_ADMIN') %}
852852
<a href="...">Delete</a>
@@ -868,7 +868,7 @@ covers all URLs (as shown before in this chapter).
868868
some internal Symfony details, to avoid broken error pages in the ``prod``
869869
environment, wrap calls in these templates with a check for ``app.user``:
870870

871-
.. code-block:: html+jinja
871+
.. code-block:: html+twig
872872

873873
{% if app.user and is_granted('ROLE_ADMIN') %}
874874

@@ -1016,7 +1016,7 @@ key:
10161016

10171017
.. configuration-block::
10181018

1019-
.. code-block:: html+jinja
1019+
.. code-block:: html+twig
10201020

10211021
{% if is_granted('IS_AUTHENTICATED_FULLY') %}
10221022
<p>Username: {{ app.user.username }}</p>

0 commit comments

Comments
 (0)