Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using {{ super() }} for extending a block #4309

Merged
merged 2 commits into from Sep 11, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
13 changes: 13 additions & 0 deletions docs/customization.md
Expand Up @@ -170,6 +170,19 @@ Then, e.g. to override the site title, add the following lines to `main.html`:
{% endblock %}
```

If you intend to add some code to a block rather than to replace it altogether with new content, use `{{ super() }}` right after the `{% block %}` statement to include the original block content. This is particularly useful when adding some third-party widgets to your docs, e.g., for chatting with support or submitting a ticket. For example, if your widget script is hosted on `widgets.example.com`, add the following lines to `main.html`:

```html
{% extends "base.html" %}

{% block scripts %}

{{ super() }}

<script id="snippet" src="https://widgets.example.com/snippet.js> </script>

{% endblock %}

The following template blocks are provided by the theme:

| Block name | Purpose |
Expand Down