From babf788636589ad75fbf44b1ce6f53996021be10 Mon Sep 17 00:00:00 2001 From: jeremy <62880356+copiri-six@users.noreply.github.com> Date: Sat, 11 Dec 2021 08:41:46 -0500 Subject: [PATCH] Proposal: Add ``header_block`` Twig Block (#1896) * Adding ``header_block`` Twig Block In attempting to remove the default green header from the API docs (I am integrating the docs into a site that already has a header), I have found that the only possible way to do so is to overwrite the entire ``index.html.twig`` file. This is because the existing ``{% header %}`` twig tags are placed *inside* the ``
`` HTML tags. So, if one overrides the ``{% header %}`` block, it only adjusts the header content, as opposed to allowing control over the entire header object. To resolve this problem I considered two methods: - Move the existing ``{% header %}`` tags _*outside*_ of the ``
`` tags. This would resolve the problem in the simplest fashion, but would be a breaking change for those currently overriding the block. - Add a new twig block, placing its tags *_outside_* the existing ``
`` tags. This would leave the existing functionality as-is, and would not break any current implementations. I chose the latter for the reasons specified above, and suggested the name ``{% header_block %}``. Thanks for considering this proposal. * Add Location of Original Twig Template This doc page advises that one can `have a look at the original template to see which blocks can be overridden`, but does not say where the original template can be found. This edit adds that information so that users don't have to resort to searching for keywords (like I just had to). Note that I haven't run any tests as this is a docs-only change. --- Resources/views/SwaggerUi/index.html.twig | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/Resources/views/SwaggerUi/index.html.twig b/Resources/views/SwaggerUi/index.html.twig index a711c25..fac6ea3 100644 --- a/Resources/views/SwaggerUi/index.html.twig +++ b/Resources/views/SwaggerUi/index.html.twig @@ -51,13 +51,16 @@ file that was distributed with this source code. #} {% endblock svg_icons %} -
- {% block header %} - - {% endblock header %} -
+ + {% block header_block %} +
+ {% block header %} + + {% endblock header %} +
+ {% endblock header_block %} {% block swagger_ui %}