Skip to content

Commit 619d64b

Browse files
committed
Create overriding-templates.md
1 parent 4980a4f commit 619d64b

File tree

1 file changed

+37
-0
lines changed

1 file changed

+37
-0
lines changed
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
Swagger UI Bundle
2+
=================
3+
4+
You can override the template used through the usual way, which is creating an `app/Resources/ALSwaggerUIBundle/views/layout.html.twig` file.
5+
6+
Here are the various Twig blocks that you need to know about:
7+
8+
`al_swagger_ui_stylesheets` - This block will contain CSS includes related to theming the `div#swagger-ui-container` portion of the documentation.
9+
`al_swagger_ui_javascripts` - This block will contain JS includes and inline scripts that effectively put the `swagger-ui` page into motion.
10+
`al_swagger_ui_content` - This block will contain the necessary HTML fragments (authentication form, `div#swagger-ui-container`, etc) that will hold `swagger-ui`-related elements.
11+
12+
All these should be present in the overriding Twig template in order for the documentation page to continue to work.
13+
14+
Example template:
15+
16+
```twig
17+
{% extends "::layout.html.twig" %}
18+
19+
{% block stylesheets %}
20+
{{ parent() }}
21+
{% block al_swagger_ui_stylesheets %}{% endblock %}
22+
<style>
23+
/** More overrides **/
24+
</style>
25+
{% endblock %}
26+
27+
{% block javascripts %}
28+
{{ parent() }}
29+
{% block al_swagger_ui_javascripts %}{% endblock %}
30+
{% endblock %}
31+
32+
{% block body %}
33+
<div class="container">
34+
{% block al_swagger_ui_content %}{% endblock %}
35+
</div>
36+
{% endblock %}
37+
```

0 commit comments

Comments
 (0)