From 57c2d4b5a8daffa36127ea236be8d447e2d5e47b Mon Sep 17 00:00:00 2001 From: WouterJ Date: Tue, 3 Nov 2015 13:14:26 +0100 Subject: [PATCH 1/2] Use Twig highlighter instead of Jinja --- best_practices/configuration.rst | 2 +- best_practices/forms.rst | 4 +- best_practices/web-assets.rst | 4 +- book/controller.rst | 2 +- book/forms.rst | 28 +++---- book/from_flat_php_to_symfony2.rst | 4 +- book/http_cache.rst | 2 +- book/page_creation.rst | 2 +- book/routing.rst | 4 +- book/security.rst | 6 +- book/templating.rst | 56 +++++++------- book/translation.rst | 10 +-- book/validation.rst | 2 +- components/form/introduction.rst | 2 +- contributing/documentation/format.rst | 4 +- cookbook/assetic/apply_to_option.rst | 6 +- cookbook/assetic/asset_management.rst | 24 +++--- cookbook/assetic/jpeg_optimize.rst | 4 +- cookbook/assetic/php.rst | 4 +- cookbook/assetic/uglifyjs.rst | 6 +- cookbook/assetic/yuicompressor.rst | 6 +- cookbook/controller/error_pages.rst | 4 +- cookbook/controller/upload_file.rst | 4 +- cookbook/doctrine/registration_form.rst | 2 +- cookbook/form/create_custom_field_type.rst | 2 +- cookbook/form/create_form_type_extension.rst | 2 +- cookbook/form/dynamic_form_modification.rst | 2 +- cookbook/form/form_collections.rst | 6 +- cookbook/form/form_customization.rst | 60 +++++++-------- cookbook/frontend/bower.rst | 2 +- cookbook/profiler/data_collector.rst | 6 +- cookbook/routing/scheme.rst | 2 +- cookbook/security/csrf_in_login_form.rst | 2 +- cookbook/security/form_login.rst | 2 +- cookbook/security/form_login_setup.rst | 2 +- cookbook/security/impersonating_user.rst | 2 +- cookbook/security/remember_me.rst | 2 +- cookbook/session/avoid_session_start.rst | 4 +- cookbook/templating/PHP.rst | 2 +- cookbook/templating/global_variables.rst | 2 +- cookbook/templating/namespaced_paths.rst | 8 +- .../templating/render_without_controller.rst | 2 +- cookbook/templating/twig_extension.rst | 4 +- quick_tour/the_big_picture.rst | 2 +- quick_tour/the_controller.rst | 6 +- quick_tour/the_view.rst | 20 ++--- reference/configuration/framework.rst | 4 +- reference/dic_tags.rst | 2 +- reference/forms/twig_reference.rst | 32 ++++---- reference/forms/types/collection.rst | 8 +- .../forms/types/options/button_label.rst.inc | 2 +- .../forms/types/options/date_widget.rst.inc | 2 +- reference/forms/types/options/label.rst.inc | 2 +- .../forms/types/options/label_attr.rst.inc | 2 +- .../types/options/preferred_choices.rst.inc | 2 +- reference/forms/types/repeated.rst | 4 +- reference/twig_reference.rst | 76 +++++++++---------- 57 files changed, 235 insertions(+), 235 deletions(-) diff --git a/best_practices/configuration.rst b/best_practices/configuration.rst index 160e707048f..7f4d99c204d 100644 --- a/best_practices/configuration.rst +++ b/best_practices/configuration.rst @@ -128,7 +128,7 @@ from places with access to the Symfony container. Constants can be used for example in your Twig templates thanks to the `constant() function`_: -.. code-block:: html+jinja +.. code-block:: html+twig

Displaying the {{ constant('NUM_ITEMS', post) }} most recent results. diff --git a/best_practices/forms.rst b/best_practices/forms.rst index 1c0bd9ba61f..b9343145a88 100644 --- a/best_practices/forms.rst +++ b/best_practices/forms.rst @@ -137,7 +137,7 @@ This is also an important error, because you are mixing presentation markup always a good practice to follow, so put all the view-related things in the view layer: -.. code-block:: html+jinja +.. code-block:: html+twig {{ form_start(form) }} {{ form_widget(form) }} @@ -157,7 +157,7 @@ One of the simplest ways - which is especially useful during development - is to render the form tags and use ``form_widget()`` to render all of the fields: -.. code-block:: html+jinja +.. code-block:: html+twig {{ form_start(form, {'attr': {'class': 'my-form-class'} }) }} {{ form_widget(form) }} diff --git a/best_practices/web-assets.rst b/best_practices/web-assets.rst index dd66ce8e2f6..a4160d62e2e 100644 --- a/best_practices/web-assets.rst +++ b/best_practices/web-assets.rst @@ -16,7 +16,7 @@ the application assets are in one location. Templates also benefit from centralizing your assets, because the links are much more concise: -.. code-block:: html+jinja +.. code-block:: html+twig @@ -54,7 +54,7 @@ of compiling assets developed with a lot of different frontend technologies like LESS, Sass and CoffeeScript. Combining all your assets with Assetic is a matter of wrapping all the assets with a single Twig tag: -.. code-block:: html+jinja +.. code-block:: html+twig {% stylesheets 'css/bootstrap.min.css' diff --git a/book/controller.rst b/book/controller.rst index 1d15b914d7b..a092c5a3fd9 100644 --- a/book/controller.rst +++ b/book/controller.rst @@ -642,7 +642,7 @@ the following code will render the ``notice`` message: .. configuration-block:: - .. code-block:: html+jinja + .. code-block:: html+twig {% for flashMessage in app.session.flashbag.get('notice') %}

diff --git a/book/forms.rst b/book/forms.rst index 8aaf2848978..3290361dd64 100644 --- a/book/forms.rst +++ b/book/forms.rst @@ -142,7 +142,7 @@ helper functions: .. configuration-block:: - .. code-block:: html+jinja + .. code-block:: html+twig {# app/Resources/views/default/new.html.twig #} {{ form_start(form) }} @@ -448,7 +448,7 @@ corresponding errors printed out with the form. .. configuration-block:: - .. code-block:: html+jinja + .. code-block:: html+twig {# app/Resources/views/default/new.html.twig #} {{ form(form, {'attr': {'novalidate': 'novalidate'}}) }} @@ -792,7 +792,7 @@ of code. Of course, you'll usually need much more flexibility when rendering: .. configuration-block:: - .. code-block:: html+jinja + .. code-block:: html+twig {# app/Resources/views/default/new.html.twig #} {{ form_start(form) }} @@ -834,7 +834,7 @@ output can be customized on many different levels. .. configuration-block:: - .. code-block:: jinja + .. code-block:: twig {{ form.vars.value.task }} @@ -856,7 +856,7 @@ used the ``form_row`` helper: .. configuration-block:: - .. code-block:: html+jinja + .. code-block:: html+twig {{ form_start(form) }} {{ form_errors(form) }} @@ -908,7 +908,7 @@ specify it: .. configuration-block:: - .. code-block:: html+jinja + .. code-block:: html+twig {{ form_label(form.task, 'Task Description') }} @@ -924,7 +924,7 @@ field: .. configuration-block:: - .. code-block:: html+jinja + .. code-block:: html+twig {{ form_widget(form.task, {'attr': {'class': 'task_field'}}) }} @@ -940,7 +940,7 @@ to get the ``id``: .. configuration-block:: - .. code-block:: html+jinja + .. code-block:: html+twig {{ form.task.vars.id }} @@ -953,7 +953,7 @@ the ``full_name`` value: .. configuration-block:: - .. code-block:: html+jinja + .. code-block:: html+twig {{ form.task.vars.full_name }} @@ -1010,7 +1010,7 @@ to the ``form()`` or the ``form_start()`` helper: .. configuration-block:: - .. code-block:: html+jinja + .. code-block:: html+twig {# app/Resources/views/default/new.html.twig #} {{ form_start(form, {'action': path('target_route'), 'method': 'GET'}) }} @@ -1384,7 +1384,7 @@ Render the ``Category`` fields in the same way as the original ``Task`` fields: .. configuration-block:: - .. code-block:: html+jinja + .. code-block:: html+twig {# ... #} @@ -1453,7 +1453,7 @@ do this, create a new template file that will store the new markup: .. configuration-block:: - .. code-block:: html+jinja + .. code-block:: html+twig {# app/Resources/views/form/fields.html.twig #} {% block form_row %} @@ -1482,7 +1482,7 @@ renders the form: .. configuration-block:: - .. code-block:: html+jinja + .. code-block:: html+twig {# app/Resources/views/default/new.html.twig #} {% form_theme form 'form/fields.html.twig' %} @@ -1671,7 +1671,7 @@ to define form output. In Twig, you can also customize a form block right inside the template where that customization is needed: - .. code-block:: html+jinja + .. code-block:: html+twig {% extends 'base.html.twig' %} diff --git a/book/from_flat_php_to_symfony2.rst b/book/from_flat_php_to_symfony2.rst index 4a2eb1a6a43..1034be2fdbf 100644 --- a/book/from_flat_php_to_symfony2.rst +++ b/book/from_flat_php_to_symfony2.rst @@ -710,7 +710,7 @@ called `Twig`_ that makes templates faster to write and easier to read. It means that the sample application could contain even less code! Take, for example, the list template written in Twig: -.. code-block:: html+jinja +.. code-block:: html+twig {# app/Resources/views/blog/list.html.twig #} {% extends "layout.html.twig" %} @@ -732,7 +732,7 @@ for example, the list template written in Twig: The corresponding ``layout.html.twig`` template is also easier to write: -.. code-block:: html+jinja +.. code-block:: html+twig {# app/Resources/views/layout.html.twig #} diff --git a/book/http_cache.rst b/book/http_cache.rst index 5cb66842ff5..571d3f7f9c0 100644 --- a/book/http_cache.rst +++ b/book/http_cache.rst @@ -1073,7 +1073,7 @@ matter), Symfony uses the standard ``render`` helper to configure ESI tags: .. configuration-block:: - .. code-block:: jinja + .. code-block:: twig {# app/Resources/views/static/about.html.twig #} diff --git a/book/page_creation.rst b/book/page_creation.rst index 2820c09d6d4..c062182d5f8 100644 --- a/book/page_creation.rst +++ b/book/page_creation.rst @@ -374,7 +374,7 @@ a ``number.html.twig`` file inside of it: .. configuration-block:: - .. code-block:: jinja + .. code-block:: twig {# app/Resources/views/lucky/number.html.twig #} {% extends 'base.html.twig' %} diff --git a/book/routing.rst b/book/routing.rst index 4476031a7c9..a2514e0a01b 100644 --- a/book/routing.rst +++ b/book/routing.rst @@ -1458,7 +1458,7 @@ a template helper function: .. configuration-block:: - .. code-block:: html+jinja + .. code-block:: html+twig Read this blog post. @@ -1491,7 +1491,7 @@ to ``generate()``: .. configuration-block:: - .. code-block:: html+jinja + .. code-block:: html+twig Read this blog post. diff --git a/book/security.rst b/book/security.rst index 1244b337e5b..8cf0a2b4174 100644 --- a/book/security.rst +++ b/book/security.rst @@ -846,7 +846,7 @@ the built-in helper function: .. configuration-block:: - .. code-block:: html+jinja + .. code-block:: html+twig {% if is_granted('ROLE_ADMIN') %} Delete @@ -868,7 +868,7 @@ covers all URLs (as shown before in this chapter). some internal Symfony details, to avoid broken error pages in the ``prod`` environment, wrap calls in these templates with a check for ``app.user``: - .. code-block:: html+jinja + .. code-block:: html+twig {% if app.user and is_granted('ROLE_ADMIN') %} @@ -1016,7 +1016,7 @@ key: .. configuration-block:: - .. code-block:: html+jinja + .. code-block:: html+twig {% if is_granted('IS_AUTHENTICATED_FULLY') %}

Username: {{ app.user.username }}

diff --git a/book/templating.rst b/book/templating.rst index 832192aad7e..7a4098269c6 100644 --- a/book/templating.rst +++ b/book/templating.rst @@ -57,7 +57,7 @@ But Symfony packages an even more powerful templating language called `Twig`_. Twig allows you to write concise, readable templates that are more friendly to web designers and, in several ways, more powerful than PHP templates: -.. code-block:: html+jinja +.. code-block:: html+twig @@ -94,7 +94,7 @@ Twig also contains **filters**, which modify content before being rendered. The following makes the ``title`` variable all uppercase before rendering it: -.. code-block:: jinja +.. code-block:: twig {{ title|upper }} @@ -111,7 +111,7 @@ and new functions can be easily added. For example, the following uses a standard ``for`` tag and the ``cycle`` function to print ten div tags, with alternating ``odd``, ``even`` classes: -.. code-block:: html+jinja +.. code-block:: html+twig {% for i in 0..10 %}
@@ -141,7 +141,7 @@ Throughout this chapter, template examples will be shown in both Twig and PHP. Take the following example, which combines a loop with a logical ``if`` statement: - .. code-block:: html+jinja + .. code-block:: html+twig