From 57c2d4b5a8daffa36127ea236be8d447e2d5e47b Mon Sep 17 00:00:00 2001 From: WouterJ Date: Tue, 3 Nov 2015 13:14:26 +0100 Subject: [PATCH 1/5] 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
    {% for user in users if user.active %} @@ -195,7 +195,7 @@ First, build a base layout file: .. configuration-block:: - .. code-block:: html+jinja + .. code-block:: html+twig {# app/Resources/views/base.html.twig #} @@ -263,7 +263,7 @@ A child template might look like this: .. configuration-block:: - .. code-block:: html+jinja + .. code-block:: html+twig {# app/Resources/views/blog/index.html.twig #} {% extends 'base.html.twig' %} @@ -360,7 +360,7 @@ When working with template inheritance, here are some tips to keep in mind: can use the ``{{ parent() }}`` function. This is useful if you want to add to the contents of a parent block instead of completely overriding it: - .. code-block:: html+jinja + .. code-block:: html+twig {% block sidebar %}

    Table of Contents

    @@ -518,7 +518,7 @@ template. First, create the template that you'll need to reuse. .. configuration-block:: - .. code-block:: html+jinja + .. code-block:: html+twig {# app/Resources/views/article/article_details.html.twig #}

    {{ article.title }}

    @@ -542,7 +542,7 @@ Including this template from any other template is simple: .. configuration-block:: - .. code-block:: html+jinja + .. code-block:: html+twig {# app/Resources/views/article/list.html.twig #} {% extends 'layout.html.twig' %} @@ -629,7 +629,7 @@ The ``recentList`` template is perfectly straightforward: .. configuration-block:: - .. code-block:: html+jinja + .. code-block:: html+twig {# app/Resources/views/article/recent_list.html.twig #} {% for article in articles %} @@ -658,7 +658,7 @@ string syntax for controllers (i.e. **bundle**:**controller**:**action**): .. configuration-block:: - .. code-block:: html+jinja + .. code-block:: html+twig {# app/Resources/views/base.html.twig #} @@ -705,7 +705,7 @@ tags: .. configuration-block:: - .. code-block:: jinja + .. code-block:: twig {{ render_hinclude(controller('...')) }} {{ render_hinclude(url('...')) }} @@ -813,7 +813,7 @@ any global default template that is defined): .. configuration-block:: - .. code-block:: jinja + .. code-block:: twig {{ render_hinclude(controller('...'), { 'default': 'default/content.html.twig' @@ -833,7 +833,7 @@ Or you can also specify a string to display as the default content: .. configuration-block:: - .. code-block:: jinja + .. code-block:: twig {{ render_hinclude(controller('...'), {'default': 'Loading...'}) }} @@ -905,7 +905,7 @@ To link to the page, just use the ``path`` Twig function and refer to the route: .. configuration-block:: - .. code-block:: html+jinja + .. code-block:: html+twig Home @@ -959,7 +959,7 @@ correctly: .. configuration-block:: - .. code-block:: html+jinja + .. code-block:: html+twig {# app/Resources/views/article/recent_list.html.twig #} {% for article in articles %} @@ -983,7 +983,7 @@ correctly: You can also generate an absolute URL by using the ``url`` Twig function: - .. code-block:: html+jinja + .. code-block:: html+twig Home @@ -1012,7 +1012,7 @@ but Symfony provides a more dynamic option via the ``asset`` Twig function: .. configuration-block:: - .. code-block:: html+jinja + .. code-block:: html+twig Symfony! @@ -1065,7 +1065,7 @@ stylesheets and JavaScripts that you'll need throughout your site: .. configuration-block:: - .. code-block:: html+jinja + .. code-block:: html+twig {# app/Resources/views/base.html.twig #} @@ -1112,7 +1112,7 @@ page. From inside that contact page's template, do the following: .. configuration-block:: - .. code-block:: html+jinja + .. code-block:: html+twig {# app/Resources/views/contact/contact.html.twig #} {% extends 'base.html.twig' %} @@ -1145,7 +1145,7 @@ You will need to run the ``php app/console assets:install target [--symlink]`` command, which moves (or symlinks) files into the correct location. (target is by default "web"). -.. code-block:: html+jinja +.. code-block:: html+twig @@ -1176,7 +1176,7 @@ automatically: .. configuration-block:: - .. code-block:: html+jinja + .. code-block:: html+twig

    Username: {{ app.user.username }}

    {% if app.debug %} @@ -1374,7 +1374,7 @@ covered: functionality would have a template called ``blog/layout.html.twig`` that contains only blog section-specific elements; - .. code-block:: html+jinja + .. code-block:: html+twig {# app/Resources/views/blog/layout.html.twig #} {% extends 'base.html.twig' %} @@ -1389,7 +1389,7 @@ covered: section template. For example, the "index" page would be called something close to ``blog/index.html.twig`` and list the actual blog posts. - .. code-block:: html+jinja + .. code-block:: html+twig {# app/Resources/views/blog/index.html.twig #} {% extends 'blog/layout.html.twig' %} @@ -1426,7 +1426,7 @@ this classic example: .. configuration-block:: - .. code-block:: html+jinja + .. code-block:: html+twig Hello {{ name }} @@ -1479,7 +1479,7 @@ HTML code. By default, Twig will escape the article body. To render it normally, add the ``raw`` filter: -.. code-block:: jinja +.. code-block:: twig {{ article.body|raw }} @@ -1520,7 +1520,7 @@ extension. Template parameters can then be dumped using the ``dump`` function: -.. code-block:: html+jinja +.. code-block:: html+twig {# app/Resources/views/article/recent_list.html.twig #} {{ dump(articles) }} @@ -1591,7 +1591,7 @@ key in the parameter hash: .. configuration-block:: - .. code-block:: html+jinja + .. code-block:: html+twig PDF Version diff --git a/book/translation.rst b/book/translation.rst index 554c8c8ba72..bb972c256bf 100644 --- a/book/translation.rst +++ b/book/translation.rst @@ -230,7 +230,7 @@ Twig Templates Symfony provides specialized Twig tags (``trans`` and ``transchoice``) to help with message translation of *static blocks of text*: -.. code-block:: jinja +.. code-block:: twig {% trans %}Hello %name%{% endtrans %} @@ -254,7 +254,7 @@ works when you use a placeholder following the ``%var%`` pattern. You can also specify the message domain and pass some additional variables: -.. code-block:: jinja +.. code-block:: twig {% trans with {'%name%': 'Fabien'} from "app" %}Hello %name%{% endtrans %} @@ -269,7 +269,7 @@ You can also specify the message domain and pass some additional variables: The ``trans`` and ``transchoice`` filters can be used to translate *variable texts* and complex expressions: -.. code-block:: jinja +.. code-block:: twig {{ message|trans }} @@ -287,7 +287,7 @@ texts* and complex expressions: that your translated message is *not* output escaped, you must apply the ``raw`` filter after the translation filter: - .. code-block:: jinja + .. code-block:: twig {# text translated between tags is never escaped #} {% trans %} @@ -304,7 +304,7 @@ texts* and complex expressions: You can set the translation domain for an entire Twig template with a single tag: - .. code-block:: jinja + .. code-block:: twig {% trans_default_domain "app" %} diff --git a/book/validation.rst b/book/validation.rst index b9b3f276f33..9da5549dfb3 100644 --- a/book/validation.rst +++ b/book/validation.rst @@ -175,7 +175,7 @@ Inside the template, you can output the list of errors exactly as needed: .. configuration-block:: - .. code-block:: html+jinja + .. code-block:: html+twig {# app/Resources/views/author/validation.html.twig #}

    The author has the following errors

    diff --git a/components/form/introduction.rst b/components/form/introduction.rst index 68695977d45..8d7b9a6d554 100644 --- a/components/form/introduction.rst +++ b/components/form/introduction.rst @@ -480,7 +480,7 @@ done by passing a special form "view" object to your template (notice the ``$form->createView()`` in the controller above) and using a set of form helper functions: -.. code-block:: html+jinja +.. code-block:: html+twig {{ form_start(form) }} {{ form_widget(form) }} diff --git a/contributing/documentation/format.rst b/contributing/documentation/format.rst index ce50f4fc974..dbd87738f80 100644 --- a/contributing/documentation/format.rst +++ b/contributing/documentation/format.rst @@ -99,8 +99,8 @@ Markup Format Use It to Display ``xml`` XML ``php`` PHP ``yaml`` YAML -``jinja`` Pure Twig markup -``html+jinja`` Twig markup blended with HTML +``twig`` Pure Twig markup +``html+twig`` Twig markup blended with HTML ``html+php`` PHP code blended with HTML ``ini`` INI ``php-annotations`` PHP Annotations diff --git a/cookbook/assetic/apply_to_option.rst b/cookbook/assetic/apply_to_option.rst index 29615b09214..22c7506075f 100644 --- a/cookbook/assetic/apply_to_option.rst +++ b/cookbook/assetic/apply_to_option.rst @@ -57,7 +57,7 @@ templates: .. configuration-block:: - .. code-block:: html+jinja + .. code-block:: html+twig {% javascripts '@AppBundle/Resources/public/js/example.coffee' filter='coffee' %} @@ -82,7 +82,7 @@ You can also combine multiple CoffeeScript files into a single output file: .. configuration-block:: - .. code-block:: html+jinja + .. code-block:: html+twig {% javascripts '@AppBundle/Resources/public/js/example.coffee' '@AppBundle/Resources/public/js/another.coffee' @@ -167,7 +167,7 @@ files being run through the CoffeeScript filter): .. configuration-block:: - .. code-block:: html+jinja + .. code-block:: html+twig {% javascripts '@AppBundle/Resources/public/js/example.coffee' '@AppBundle/Resources/public/js/another.coffee' diff --git a/cookbook/assetic/asset_management.rst b/cookbook/assetic/asset_management.rst index 16dc5d6b568..af0055f5795 100644 --- a/cookbook/assetic/asset_management.rst +++ b/cookbook/assetic/asset_management.rst @@ -16,7 +16,7 @@ directly: .. configuration-block:: - .. code-block:: html+jinja + .. code-block:: html+twig @@ -57,7 +57,7 @@ To include JavaScript files, use the ``javascripts`` tag in any template: .. configuration-block:: - .. code-block:: html+jinja + .. code-block:: html+twig {% javascripts '@AppBundle/Resources/public/js/*' %} @@ -77,7 +77,7 @@ To include JavaScript files, use the ``javascripts`` tag in any template: Standard Edition, the ``javascripts`` tag will most commonly live in the ``javascripts`` block: - .. code-block:: html+jinja + .. code-block:: html+twig {# ... #} {% block javascripts %} @@ -113,7 +113,7 @@ except with the ``stylesheets`` tag: .. configuration-block:: - .. code-block:: html+jinja + .. code-block:: html+twig {% stylesheets 'bundles/app/css/*' filter='cssrewrite' %} @@ -134,7 +134,7 @@ except with the ``stylesheets`` tag: Standard Edition, the ``stylesheets`` tag will most commonly live in the ``stylesheets`` block: - .. code-block:: html+jinja + .. code-block:: html+twig {# ... #} {% block stylesheets %} @@ -166,7 +166,7 @@ To include an image you can use the ``image`` tag. .. configuration-block:: - .. code-block:: html+jinja + .. code-block:: html+twig {% image '@AppBundle/Resources/public/images/example.jpg' %} Example @@ -218,7 +218,7 @@ but still serve them as a single file: .. configuration-block:: - .. code-block:: html+jinja + .. code-block:: html+twig {% javascripts '@AppBundle/Resources/public/js/*' @@ -257,7 +257,7 @@ combine third party assets, such as jQuery, with your own into a single file: .. configuration-block:: - .. code-block:: html+jinja + .. code-block:: html+twig {% javascripts '@AppBundle/Resources/public/js/thirdparty/jquery.js' @@ -330,7 +330,7 @@ with the ``@named_asset`` notation: .. configuration-block:: - .. code-block:: html+jinja + .. code-block:: html+twig {% javascripts '@jquery_and_ui' @@ -410,7 +410,7 @@ into your template: .. configuration-block:: - .. code-block:: html+jinja + .. code-block:: html+twig {% javascripts '@AppBundle/Resources/public/js/*' filter='uglifyjs2' %} @@ -436,7 +436,7 @@ done from the template and is relative to the public document root: .. configuration-block:: - .. code-block:: html+jinja + .. code-block:: html+twig {% javascripts '@AppBundle/Resources/public/js/*' output='js/compiled/main.js' %} @@ -563,7 +563,7 @@ some isolated directory (e.g. ``/js/compiled``), to keep things organized: .. configuration-block:: - .. code-block:: html+jinja + .. code-block:: html+twig {% javascripts '@AppBundle/Resources/public/js/*' output='js/compiled/main.js' %} diff --git a/cookbook/assetic/jpeg_optimize.rst b/cookbook/assetic/jpeg_optimize.rst index 3007dabf800..c55a32dc800 100644 --- a/cookbook/assetic/jpeg_optimize.rst +++ b/cookbook/assetic/jpeg_optimize.rst @@ -51,7 +51,7 @@ It can now be used from a template: .. configuration-block:: - .. code-block:: html+jinja + .. code-block:: html+twig {% image '@AppBundle/Resources/public/images/example.jpg' filter='jpegoptim' output='/images/example.jpg' %} @@ -198,7 +198,7 @@ following configuration: The Twig template can now be changed to the following: -.. code-block:: html+jinja +.. code-block:: html+twig Example diff --git a/cookbook/assetic/php.rst b/cookbook/assetic/php.rst index 29782359f8c..c7e8c2e6b26 100644 --- a/cookbook/assetic/php.rst +++ b/cookbook/assetic/php.rst @@ -119,7 +119,7 @@ the original files are regular CSS files or SCSS files. Next, update your Twig template to add the ``{% stylesheets %}`` tag defined by Assetic: -.. code-block:: html+jinja +.. code-block:: html+twig {# app/Resources/views/base.html.twig #} @@ -180,7 +180,7 @@ First, configure a new ``jsqueeze`` Assetic filter as follows: Next, update the code of your Twig template to add the ``{% javascripts %}`` tag defined by Assetic: -.. code-block:: html+jinja +.. code-block:: html+twig diff --git a/cookbook/assetic/uglifyjs.rst b/cookbook/assetic/uglifyjs.rst index 5c4b4d3a04c..a08569647a3 100644 --- a/cookbook/assetic/uglifyjs.rst +++ b/cookbook/assetic/uglifyjs.rst @@ -163,7 +163,7 @@ asset tags of your templates to tell Assetic to use the ``uglifyjs2`` filter: .. configuration-block:: - .. code-block:: html+jinja + .. code-block:: html+twig {% javascripts '@AppBundle/Resources/public/js/*' filter='uglifyjs2' %} @@ -198,7 +198,7 @@ apply this filter when debug mode is off (e.g. ``app.php``): .. configuration-block:: - .. code-block:: html+jinja + .. code-block:: html+twig {% javascripts '@AppBundle/Resources/public/js/*' filter='?uglifyjs2' %} @@ -275,7 +275,7 @@ helper: .. configuration-block:: - .. code-block:: html+jinja + .. code-block:: html+twig {% stylesheets 'bundles/App/css/*' filter='uglifycss' filter='cssrewrite' %} diff --git a/cookbook/assetic/yuicompressor.rst b/cookbook/assetic/yuicompressor.rst index 2fe5ea134ef..66cb5364ec7 100644 --- a/cookbook/assetic/yuicompressor.rst +++ b/cookbook/assetic/yuicompressor.rst @@ -85,7 +85,7 @@ the view layer, this work is done in your templates: .. configuration-block:: - .. code-block:: html+jinja + .. code-block:: html+twig {% javascripts '@AppBundle/Resources/public/js/*' filter='yui_js' %} @@ -113,7 +113,7 @@ can be repeated to minify your stylesheets. .. configuration-block:: - .. code-block:: html+jinja + .. code-block:: html+twig {% stylesheets '@AppBundle/Resources/public/css/*' filter='yui_css' %} @@ -139,7 +139,7 @@ apply this filter when debug mode is off. .. configuration-block:: - .. code-block:: html+jinja + .. code-block:: html+twig {% javascripts '@AppBundle/Resources/public/js/*' filter='?yui_js' %} diff --git a/cookbook/controller/error_pages.rst b/cookbook/controller/error_pages.rst index e2a5de8acc3..277103582a3 100644 --- a/cookbook/controller/error_pages.rst +++ b/cookbook/controller/error_pages.rst @@ -87,7 +87,7 @@ Example 404 Error Template To override the 404 error template for HTML pages, create a new ``error404.html.twig`` template located at ``app/Resources/TwigBundle/views/Exception/``: -.. code-block:: html+jinja +.. code-block:: html+twig {# app/Resources/TwigBundle/views/Exception/error404.html.twig #} {% extends 'base.html.twig' %} @@ -136,7 +136,7 @@ The cause of this problem is that routing is done before security. If a 404 erro occurs, the security layer isn't loaded and thus, the ``is_granted()`` function is undefined. The solution is to add the following check before using this function: -.. code-block:: jinja +.. code-block:: twig {% if app.user and is_granted('...') %} {# ... #} diff --git a/cookbook/controller/upload_file.rst b/cookbook/controller/upload_file.rst index 087ae4d47ab..065b4bbaf0a 100644 --- a/cookbook/controller/upload_file.rst +++ b/cookbook/controller/upload_file.rst @@ -86,7 +86,7 @@ Now, update the template that renders the form to display the new ``brochure`` field (the exact template code to add depends on the method used by your application to :doc:`customize form rendering `): -.. code-block:: html+jinja +.. code-block:: html+twig {# app/Resources/views/product/new.html.twig #}

    Adding a new product

    @@ -171,7 +171,7 @@ There are some important things to consider in the code of the above controller: You can now use the following code to link to the PDF brochure of an product: -.. code-block:: html+jinja +.. code-block:: html+twig
    View brochure (PDF) diff --git a/cookbook/doctrine/registration_form.rst b/cookbook/doctrine/registration_form.rst index 47e6873b008..48a70ad051e 100644 --- a/cookbook/doctrine/registration_form.rst +++ b/cookbook/doctrine/registration_form.rst @@ -293,7 +293,7 @@ Next, create the template: .. configuration-block:: - .. code-block:: html+jinja + .. code-block:: html+twig {# app/Resources/views/registration/register.html.twig #} diff --git a/cookbook/form/create_custom_field_type.rst b/cookbook/form/create_custom_field_type.rst index 364b045e587..a41bfa980ba 100644 --- a/cookbook/form/create_custom_field_type.rst +++ b/cookbook/form/create_custom_field_type.rst @@ -109,7 +109,7 @@ link for details), create a ``gender_widget`` block to handle this: .. configuration-block:: - .. code-block:: html+jinja + .. code-block:: html+twig {# app/Resources/views/Form/fields.html.twig #} {% block gender_widget %} diff --git a/cookbook/form/create_form_type_extension.rst b/cookbook/form/create_form_type_extension.rst index eb1fb4d6a70..153b0b7fc57 100644 --- a/cookbook/form/create_form_type_extension.rst +++ b/cookbook/form/create_form_type_extension.rst @@ -257,7 +257,7 @@ Specifically, you need to override the ``file_widget`` block: .. configuration-block:: - .. code-block:: html+jinja + .. code-block:: html+twig {# src/AppBundle/Resources/views/Form/fields.html.twig #} {% extends 'form_div_layout.html.twig' %} diff --git a/cookbook/form/dynamic_form_modification.rst b/cookbook/form/dynamic_form_modification.rst index 5b1a33db06e..df49ff753c9 100644 --- a/cookbook/form/dynamic_form_modification.rst +++ b/cookbook/form/dynamic_form_modification.rst @@ -630,7 +630,7 @@ field according to the current selection in the ``sport`` field: .. configuration-block:: - .. code-block:: html+jinja + .. code-block:: html+twig {# app/Resources/views/Meetup/create.html.twig #} {{ form_start(form) }} diff --git a/cookbook/form/form_collections.rst b/cookbook/form/form_collections.rst index 8fde88be08a..542a868c65f 100644 --- a/cookbook/form/form_collections.rst +++ b/cookbook/form/form_collections.rst @@ -191,7 +191,7 @@ zero tags when first created). .. configuration-block:: - .. code-block:: html+jinja + .. code-block:: html+twig {# src/AppBundle/Resources/views/Task/new.html.twig #} @@ -297,7 +297,7 @@ new "tag" forms. To render it, make the following change to your template: .. configuration-block:: - .. code-block:: html+jinja + .. code-block:: html+twig
      ... @@ -325,7 +325,7 @@ new "tag" forms. To render it, make the following change to your template: on it. You could even choose to render only one of its fields (e.g. the ``name`` field): - .. code-block:: html+jinja + .. code-block:: html+twig {{ form_widget(form.tags.vars.prototype.name)|e }} diff --git a/cookbook/form/form_customization.rst b/cookbook/form/form_customization.rst index 9f7b07fb7bb..18d05ebfb1d 100644 --- a/cookbook/form/form_customization.rst +++ b/cookbook/form/form_customization.rst @@ -18,7 +18,7 @@ method: .. configuration-block:: - .. code-block:: jinja + .. code-block:: twig {{ form_row(form.age) }} @@ -30,7 +30,7 @@ You can also render each of the three parts of the field individually: .. configuration-block:: - .. code-block:: html+jinja + .. code-block:: html+twig
      {{ form_label(form.age) }} @@ -65,7 +65,7 @@ just one line: .. configuration-block:: - .. code-block:: jinja + .. code-block:: twig {# renders all fields #} {{ form_widget(form) }} @@ -113,7 +113,7 @@ For example, when the widget of an ``integer`` type field is rendered, an ``inpu .. configuration-block:: - .. code-block:: html+jinja + .. code-block:: html+twig {{ form_widget(form.age) }} @@ -141,7 +141,7 @@ The default implementation of the ``integer_widget`` fragment looks like this: .. configuration-block:: - .. code-block:: jinja + .. code-block:: twig {# form_div_layout.html.twig #} {% block integer_widget %} @@ -158,7 +158,7 @@ As you can see, this fragment itself renders another fragment - ``form_widget_si .. configuration-block:: - .. code-block:: html+jinja + .. code-block:: html+twig {# form_div_layout.html.twig #} {% block form_widget_simple %} @@ -241,7 +241,7 @@ Method 1: Inside the same Template as the Form The easiest way to customize the ``integer_widget`` block is to customize it directly in the template that's actually rendering the form. -.. code-block:: html+jinja +.. code-block:: html+twig {% extends '::base.html.twig' %} @@ -280,7 +280,7 @@ You can also choose to put the customized ``integer_widget`` form block in a separate template entirely. The code and end-result are the same, but you can now re-use the form customization across many templates: -.. code-block:: html+jinja +.. code-block:: html+twig {# app/Resources/views/Form/fields.html.twig #} {% block integer_widget %} @@ -296,7 +296,7 @@ tell Symfony to use the template via the ``form_theme`` tag: .. _cookbook-form-twig-theme-import-template: -.. code-block:: html+jinja +.. code-block:: html+twig {% form_theme form 'AppBundle:Form:fields.html.twig' %} @@ -312,7 +312,7 @@ Multiple Templates A form can also be customized by applying several templates. To do this, pass the name of all the templates as an array using the ``with`` keyword: -.. code-block:: html+jinja +.. code-block:: html+twig {% form_theme form with ['::common.html.twig', ':Form:fields.html.twig', 'AppBundle:Form:fields.html.twig'] %} @@ -327,14 +327,14 @@ Child Forms You can also apply a form theme to a specific child of your form: -.. code-block:: html+jinja +.. code-block:: html+twig {% form_theme form.child 'AppBundle:Form:fields.html.twig' %} This is useful when you want to have a custom theme for a nested form that's different than the one of your main form. Just specify both your themes: -.. code-block:: html+jinja +.. code-block:: html+twig {% form_theme form 'AppBundle:Form:fields.html.twig' %} @@ -401,7 +401,7 @@ Referencing Blocks from inside the same Template as the Form Import the blocks by adding a ``use`` tag in the template where you're rendering the form: -.. code-block:: jinja +.. code-block:: twig {% use 'form_div_layout.html.twig' with integer_widget as base_integer_widget %} @@ -410,7 +410,7 @@ Now, when the blocks from `form_div_layout.html.twig`_ are imported, the you redefine the ``integer_widget`` block, you can reference the default markup via ``base_integer_widget``: -.. code-block:: html+jinja +.. code-block:: html+twig {% block integer_widget %}
      @@ -424,7 +424,7 @@ Referencing base Blocks from an external Template If your form customizations live inside an external template, you can reference the base block by using the ``parent()`` Twig function: -.. code-block:: html+jinja +.. code-block:: html+twig {# app/Resources/views/Form/fields.html.twig #} {% extends 'form_div_layout.html.twig' %} @@ -532,7 +532,7 @@ resource to use such a layout: If you only want to make the change in one template, add the following line to your template file rather than adding the template as a resource: -.. code-block:: html+jinja +.. code-block:: html+twig {% form_theme form 'form_table_layout.html.twig' %} @@ -651,7 +651,7 @@ customize the ``name`` field only: .. configuration-block:: - .. code-block:: html+jinja + .. code-block:: html+twig {% form_theme form _self %} @@ -706,7 +706,7 @@ You can also override the markup for an entire field row using the same method: .. configuration-block:: - .. code-block:: html+jinja + .. code-block:: html+twig {% form_theme form _self %} @@ -746,7 +746,7 @@ will be able to change the widget for each task as follows: .. configuration-block:: - .. code-block:: html+jinja + .. code-block:: html+twig {% form_theme form _self %} @@ -804,7 +804,7 @@ when you use the ``form_errors`` helper: .. configuration-block:: - .. code-block:: jinja + .. code-block:: twig {{ form_errors(form.age) }} @@ -825,7 +825,7 @@ and customize the ``form_errors`` fragment. .. configuration-block:: - .. code-block:: html+jinja + .. code-block:: html+twig {# form_errors.html.twig #} {% block form_errors %} @@ -870,7 +870,7 @@ field) are rendered separately, usually at the top of your form: .. configuration-block:: - .. code-block:: jinja + .. code-block:: twig {{ form_errors(form) }} @@ -885,7 +885,7 @@ fields (e.g. a whole form), and not just an individual field. .. configuration-block:: - .. code-block:: html+jinja + .. code-block:: html+twig {# form_errors.html.twig #} {% block form_errors %} @@ -931,7 +931,7 @@ class to the ``div`` element around each row: .. configuration-block:: - .. code-block:: html+jinja + .. code-block:: html+twig {# form_row.html.twig #} {% block form_row %} @@ -964,7 +964,7 @@ you can do this by customizing the ``form_label`` fragment. In Twig, if you're making the form customization inside the same template as your form, modify the ``use`` tag and add the following: -.. code-block:: html+jinja +.. code-block:: html+twig {% use 'form_div_layout.html.twig' with form_label as base_form_label %} @@ -979,7 +979,7 @@ form, modify the ``use`` tag and add the following: In Twig, if you're making the form customization inside a separate template, use the following: -.. code-block:: html+jinja +.. code-block:: html+twig {% extends 'form_div_layout.html.twig' %} @@ -1032,7 +1032,7 @@ You can also customize your form widgets to have an optional "help" message. In Twig, if you're making the form customization inside the same template as your form, modify the ``use`` tag and add the following: -.. code-block:: html+jinja +.. code-block:: html+twig {% use 'form_div_layout.html.twig' with form_widget_simple as base_form_widget_simple %} @@ -1047,7 +1047,7 @@ form, modify the ``use`` tag and add the following: In Twig, if you're making the form customization inside a separate template, use the following: -.. code-block:: html+jinja +.. code-block:: html+twig {% extends 'form_div_layout.html.twig' %} @@ -1082,7 +1082,7 @@ To render a help message below a field, pass in a ``help`` variable: .. configuration-block:: - .. code-block:: jinja + .. code-block:: twig {{ form_widget(form.title, {'help': 'foobar'}) }} @@ -1103,7 +1103,7 @@ customizations directly. Look at the following example: .. configuration-block:: - .. code-block:: jinja + .. code-block:: twig {# render a widget, but add a "foo" class to it #} {{ form_widget(form.name, { 'attr': {'class': 'foo'} }) }} diff --git a/cookbook/frontend/bower.rst b/cookbook/frontend/bower.rst index c12730e0646..39ba43f9802 100644 --- a/cookbook/frontend/bower.rst +++ b/cookbook/frontend/bower.rst @@ -82,7 +82,7 @@ template like normal CSS/JS: .. configuration-block:: - .. code-block:: html+jinja + .. code-block:: html+twig {# app/Resources/views/layout.html.twig #} diff --git a/cookbook/profiler/data_collector.rst b/cookbook/profiler/data_collector.rst index 47229033063..0e2d410413b 100644 --- a/cookbook/profiler/data_collector.rst +++ b/cookbook/profiler/data_collector.rst @@ -131,7 +131,7 @@ In the simplest case, you just want to display the information in the toolbar without providing a profiler panel. This requires to define the ``toolbar`` block and set the value of two variables called ``icon`` and ``text``: -.. code-block:: html+jinja +.. code-block:: html+twig {% extends 'WebProfilerBundle:Profiler:layout.html.twig' %} @@ -174,7 +174,7 @@ block and set the value of two variables called ``icon`` and ``text``: resolution-independent, these images can be easily embedded in the Twig template or included from an external file to reuse them in several templates: - .. code-block:: jinja + .. code-block:: twig {{ include('@App/data_collector/icon.svg') }} @@ -183,7 +183,7 @@ block and set the value of two variables called ``icon`` and ``text``: If the toolbar panel includes extended web profiler information, the Twig template must also define additional blocks: -.. code-block:: html+jinja +.. code-block:: html+twig {% extends '@WebProfiler/Profiler/layout.html.twig' %} diff --git a/cookbook/routing/scheme.rst b/cookbook/routing/scheme.rst index f643e1bd946..927b6e3900d 100644 --- a/cookbook/routing/scheme.rst +++ b/cookbook/routing/scheme.rst @@ -47,7 +47,7 @@ The above configuration forces the ``secure`` route to always use HTTPS. When generating the ``secure`` URL, and if the current scheme is HTTP, Symfony will automatically generate an absolute URL with HTTPS as the scheme: -.. code-block:: jinja +.. code-block:: twig {# If the current scheme is HTTPS #} {{ path('secure') }} diff --git a/cookbook/security/csrf_in_login_form.rst b/cookbook/security/csrf_in_login_form.rst index a5d1474ec5f..f98cc160fa9 100644 --- a/cookbook/security/csrf_in_login_form.rst +++ b/cookbook/security/csrf_in_login_form.rst @@ -87,7 +87,7 @@ using the login form: .. configuration-block:: - .. code-block:: html+jinja + .. code-block:: html+twig {# src/AppBundle/Resources/views/Security/login.html.twig #} diff --git a/cookbook/security/form_login.rst b/cookbook/security/form_login.rst index 766f69a8101..b4b5713b531 100644 --- a/cookbook/security/form_login.rst +++ b/cookbook/security/form_login.rst @@ -227,7 +227,7 @@ redirect to the URL defined by some ``account`` route, use the following: .. configuration-block:: - .. code-block:: html+jinja + .. code-block:: html+twig {# src/AppBundle/Resources/views/Security/login.html.twig #} {% if error %} diff --git a/cookbook/security/form_login_setup.rst b/cookbook/security/form_login_setup.rst index ea3981c7760..a1c3e3a1a05 100644 --- a/cookbook/security/form_login_setup.rst +++ b/cookbook/security/form_login_setup.rst @@ -218,7 +218,7 @@ Finally, create the template: .. configuration-block:: - .. code-block:: html+jinja + .. code-block:: html+twig {# app/Resources/views/security/login.html.twig #} {# ... you will probably extends your base template, like base.html.twig #} diff --git a/cookbook/security/impersonating_user.rst b/cookbook/security/impersonating_user.rst index c2e91d40007..53da2368763 100644 --- a/cookbook/security/impersonating_user.rst +++ b/cookbook/security/impersonating_user.rst @@ -75,7 +75,7 @@ to show a link to exit impersonation: .. configuration-block:: - .. code-block:: html+jinja + .. code-block:: html+twig {% if is_granted('ROLE_PREVIOUS_ADMIN') %} Exit impersonation diff --git a/cookbook/security/remember_me.rst b/cookbook/security/remember_me.rst index f820dfa0dd4..68c6daaab2c 100644 --- a/cookbook/security/remember_me.rst +++ b/cookbook/security/remember_me.rst @@ -145,7 +145,7 @@ this: .. configuration-block:: - .. code-block:: html+jinja + .. code-block:: html+twig {# app/Resources/views/security/login.html.twig #} {% if error %} diff --git a/cookbook/session/avoid_session_start.rst b/cookbook/session/avoid_session_start.rst index 68b58aa3ea4..87e798b6313 100644 --- a/cookbook/session/avoid_session_start.rst +++ b/cookbook/session/avoid_session_start.rst @@ -13,7 +13,7 @@ For example, one common problem in this situation involves checking for flash messages, which are stored in the session. The following code would guarantee that a session is *always* started: -.. code-block:: html+jinja +.. code-block:: html+twig {% for flashMessage in app.session.flashbag.get('notice') %}
      @@ -27,7 +27,7 @@ start a session. This may hurt your application performance because all users wi receive a session cookie. To avoid this behavior, add a check before trying to access the flash messages: -.. code-block:: html+jinja +.. code-block:: html+twig {% if app.request.hasPreviousSession %} {% for flashMessage in app.session.flashbag.get('notice') %} diff --git a/cookbook/templating/PHP.rst b/cookbook/templating/PHP.rst index 4d1ec295b30..b91ed0323cf 100644 --- a/cookbook/templating/PHP.rst +++ b/cookbook/templating/PHP.rst @@ -94,7 +94,7 @@ You can also use the `@Template`_ shortcut to render the default $this->render('AppBundle:Default:index.html.twig'); } - .. code-block:: jinja + .. code-block:: twig {# inside a Twig template, namespaced templates work as expected #} {{ include('@App/Default/index.html.twig') }} diff --git a/cookbook/templating/global_variables.rst b/cookbook/templating/global_variables.rst index 0226b3cf9ec..fc7b8a309ea 100644 --- a/cookbook/templating/global_variables.rst +++ b/cookbook/templating/global_variables.rst @@ -37,7 +37,7 @@ This is possible inside your ``app/config/config.yml`` file: Now, the variable ``ga_tracking`` is available in all Twig templates: -.. code-block:: html+jinja +.. code-block:: html+twig

      The google tracking code is: {{ ga_tracking }}

      diff --git a/cookbook/templating/namespaced_paths.rst b/cookbook/templating/namespaced_paths.rst index 6e90e3958c9..5ecaf59cd02 100644 --- a/cookbook/templating/namespaced_paths.rst +++ b/cookbook/templating/namespaced_paths.rst @@ -15,14 +15,14 @@ is built-in automatically for all of your bundles. Take the following paths as an example: -.. code-block:: jinja +.. code-block:: twig {% extends "AppBundle::layout.html.twig" %} {{ include('AppBundle:Foo:bar.html.twig') }} With namespaced paths, the following works as well: -.. code-block:: jinja +.. code-block:: twig {% extends "@App/layout.html.twig" %} {{ include('@App/Foo/bar.html.twig') }} @@ -85,7 +85,7 @@ The registered namespace is called ``foo_bar``, which refers to the ``vendor/acme/foo-bar/templates`` directory. Assuming there's a file called ``sidebar.twig`` in that directory, you can use it easily: -.. code-block:: jinja +.. code-block:: twig {{ include('@foo_bar/sidebar.twig') }} @@ -139,6 +139,6 @@ specific template doesn't exist. Now, you can use the same ``@theme`` namespace to refer to any template located in the previous three directories: -.. code-block:: jinja +.. code-block:: twig {{ include('@theme/header.twig') }} diff --git a/cookbook/templating/render_without_controller.rst b/cookbook/templating/render_without_controller.rst index cd9a6b8fc70..4ab84e20916 100644 --- a/cookbook/templating/render_without_controller.rst +++ b/cookbook/templating/render_without_controller.rst @@ -62,7 +62,7 @@ this is probably only useful if you'd like to cache this page partial (see .. configuration-block:: - .. code-block:: html+jinja + .. code-block:: html+twig {{ render(url('acme_privacy')) }} diff --git a/cookbook/templating/twig_extension.rst b/cookbook/templating/twig_extension.rst index 0b580406dd8..679da017618 100644 --- a/cookbook/templating/twig_extension.rst +++ b/cookbook/templating/twig_extension.rst @@ -114,14 +114,14 @@ Using the custom Extension Using your newly created Twig Extension is no different than any other: -.. code-block:: jinja +.. code-block:: twig {# outputs $5,500.00 #} {{ '5500'|price }} Passing other arguments to your filter: -.. code-block:: jinja +.. code-block:: twig {# outputs $5500,2516 #} {{ '5500.25155'|price(4, ',', '') }} diff --git a/quick_tour/the_big_picture.rst b/quick_tour/the_big_picture.rst index cdc7dd92d7f..af5edbeab18 100644 --- a/quick_tour/the_big_picture.rst +++ b/quick_tour/the_big_picture.rst @@ -145,7 +145,7 @@ directory. Therefore, the ``default/index.html.twig`` template corresponds to the ``app/Resources/views/default/index.html.twig``. Open that file and you'll see the following code: -.. code-block:: html+jinja +.. code-block:: html+twig {# app/Resources/views/default/index.html.twig #} {% extends 'base.html.twig' %} diff --git a/quick_tour/the_controller.rst b/quick_tour/the_controller.rst index d3bde2ed14b..07f30142699 100644 --- a/quick_tour/the_controller.rst +++ b/quick_tour/the_controller.rst @@ -83,7 +83,7 @@ this error is that we're trying to render a template Create the new ``app/Resources/views/default/hello.html.twig`` template with the following content: -.. code-block:: html+jinja +.. code-block:: html+twig {# app/Resources/views/default/hello.html.twig #} {% extends 'base.html.twig' %} @@ -281,7 +281,7 @@ forget to add the new ``use`` statement that imports this ``Request`` class):: In a template, you can also access the ``Request`` object via the special ``app.request`` variable automatically provided by Symfony: -.. code-block:: html+jinja +.. code-block:: html+twig {{ app.request.query.get('page') }} @@ -328,7 +328,7 @@ redirecting the user to another page (which will then show the message):: And you can display the flash message in the template like this: -.. code-block:: html+jinja +.. code-block:: html+twig {% for flashMessage in app.session.flashbag.get('notice') %}
      diff --git a/quick_tour/the_view.rst b/quick_tour/the_view.rst index d05044037aa..7609730f916 100644 --- a/quick_tour/the_view.rst +++ b/quick_tour/the_view.rst @@ -32,7 +32,7 @@ the rest of the template contents using any of these delimiters: Below is a minimal template that illustrates a few basics, using two variables ``page_title`` and ``navigation``, which would be passed into the template: -.. code-block:: html+jinja +.. code-block:: html+twig @@ -64,7 +64,7 @@ a variable with the dot (``.``) notation. The following code listing shows how to display the content of a variable passed by the controller depending on its type: -.. code-block:: jinja +.. code-block:: twig {# 1. Simple variables #} {# $this->render('template.html.twig', array( @@ -104,7 +104,7 @@ defines "blocks" of contents that child templates can override. The ``index.html.twig`` template uses the ``extends`` tag to indicate that it inherits from the ``base.html.twig`` template: -.. code-block:: html+jinja +.. code-block:: html+twig {# app/Resources/views/default/index.html.twig #} {% extends 'base.html.twig' %} @@ -116,7 +116,7 @@ it inherits from the ``base.html.twig`` template: Open the ``app/Resources/views/base.html.twig`` file that corresponds to the ``base.html.twig`` template and you'll find the following Twig code: -.. code-block:: html+jinja +.. code-block:: html+twig {# app/Resources/views/base.html.twig #} @@ -146,7 +146,7 @@ One of the best features of Twig is its extensibility via tags, filters and functions. Take a look at the following sample template that uses filters extensively to modify the information before displaying it to the user: -.. code-block:: jinja +.. code-block:: twig

      {{ article.title|capitalize }}

      @@ -168,7 +168,7 @@ create a new template fragment that can then be included from other templates. Imagine that we want to display ads on some pages of our application. First, create a ``banner.html.twig`` template: -.. code-block:: jinja +.. code-block:: twig {# app/Resources/views/ads/banner.html.twig #}
      @@ -178,7 +178,7 @@ create a ``banner.html.twig`` template: To display this ad on any page, include the ``banner.html.twig`` template using the ``include()`` function: -.. code-block:: html+jinja +.. code-block:: html+twig {# app/Resources/views/default/index.html.twig #} {% extends 'base.html.twig' %} @@ -201,7 +201,7 @@ the most popular articles of your website. If you want to "render" the result of that method (usually some HTML content) inside the ``index`` template, use the ``render()`` function: -.. code-block:: jinja +.. code-block:: twig {# app/Resources/views/index.html.twig #} {{ render(controller('AppBundle:Default:topArticles')) }} @@ -236,7 +236,7 @@ hardcoding URLs in templates, the ``path`` function knows how to generate URLs based on the routing configuration. That way, all your URLs can be easily updated by just changing the configuration: -.. code-block:: html+jinja +.. code-block:: html+twig Return to homepage @@ -255,7 +255,7 @@ Including Assets: Images, JavaScripts and Stylesheets What would the Internet be without images, JavaScripts and stylesheets? Symfony provides the ``asset`` function to deal with them easily: -.. code-block:: jinja +.. code-block:: twig diff --git a/reference/configuration/framework.rst b/reference/configuration/framework.rst index 92e08e4498a..ccd60c8e1c1 100644 --- a/reference/configuration/framework.rst +++ b/reference/configuration/framework.rst @@ -859,7 +859,7 @@ For example, suppose you have the following: .. configuration-block:: - .. code-block:: html+jinja + .. code-block:: html+twig Symfony! @@ -1250,7 +1250,7 @@ Now you can use the ``avatars`` package in your templates: .. configuration-block:: php - .. code-block:: html+jinja + .. code-block:: html+twig diff --git a/reference/dic_tags.rst b/reference/dic_tags.rst index a1d28cc92d7..d592d051f73 100644 --- a/reference/dic_tags.rst +++ b/reference/dic_tags.rst @@ -206,7 +206,7 @@ Second, define a service: Finally, apply the filter: -.. code-block:: jinja +.. code-block:: twig {% javascripts '@AcmeBaseBundle/Resources/public/js/global.js' diff --git a/reference/forms/twig_reference.rst b/reference/forms/twig_reference.rst index 80010c8b914..ba2d4b46f91 100644 --- a/reference/forms/twig_reference.rst +++ b/reference/forms/twig_reference.rst @@ -33,7 +33,7 @@ form(view, variables) Renders the HTML of a complete form. -.. code-block:: jinja +.. code-block:: twig {# render the form and change the submission method #} {{ form(form, {'method': 'GET'}) }} @@ -42,7 +42,7 @@ You will mostly use this helper for prototyping or if you use custom form themes. If you need more flexibility in rendering the form, you should use the other helpers to render individual parts of the form instead: -.. code-block:: jinja +.. code-block:: twig {{ form_start(form) }} {{ form_errors(form) }} @@ -62,7 +62,7 @@ Renders the start tag of a form. This helper takes care of printing the configured method and target action of the form. It will also include the correct ``enctype`` property if the form contains upload fields. -.. code-block:: jinja +.. code-block:: twig {# render the start tag and change the submission method #} {{ form_start(form, {'method': 'GET'}) }} @@ -74,14 +74,14 @@ form_end(view, variables) Renders the end tag of a form. -.. code-block:: jinja +.. code-block:: twig {{ form_end(form) }} This helper also outputs ``form_rest()`` unless you set ``render_rest`` to false: -.. code-block:: jinja +.. code-block:: twig {# don't render unrendered fields #} {{ form_end(form, {'render_rest': false}) }} @@ -94,7 +94,7 @@ form_label(view, label, variables) Renders the label for the given field. You can optionally pass the specific label you want to display as the second argument. -.. code-block:: jinja +.. code-block:: twig {{ form_label(form.name) }} @@ -116,7 +116,7 @@ form_errors(view) Renders any errors for the given field. -.. code-block:: jinja +.. code-block:: twig {{ form_errors(form.name) }} @@ -131,7 +131,7 @@ form_widget(view, variables) Renders the HTML widget of a given field. If you apply this to an entire form or collection of fields, each underlying form row will be rendered. -.. code-block:: jinja +.. code-block:: twig {# render a widget, but add a "foo" class to it #} {{ form_widget(form.name, {'attr': {'class': 'foo'}}) }} @@ -154,7 +154,7 @@ form_row(view, variables) Renders the "row" of a given field, which is the combination of the field's label, errors and widget. -.. code-block:: jinja +.. code-block:: twig {# render a field row, but display a label with text "foo" #} {{ form_row(form.name, {'label': 'foo'}) }} @@ -176,7 +176,7 @@ It's a good idea to always have this somewhere inside your form as it'll render hidden fields for you and make any fields you forgot to render more obvious (since it'll render the field for you). -.. code-block:: jinja +.. code-block:: twig {{ form_rest(form) }} @@ -194,7 +194,7 @@ If the form contains at least one file upload field, this will render the required ``enctype="multipart/form-data"`` form attribute. It's always a good idea to include this in your form tag: -.. code-block:: html+jinja +.. code-block:: html+twig
      @@ -213,7 +213,7 @@ This test will check if the current choice is equal to the ``selected_value`` or if the current choice is in the array (when ``selected_value`` is an array). -.. code-block:: jinja +.. code-block:: twig