Skip to content

Commit

Permalink
Added body_scripts block to base template (#687)
Browse files Browse the repository at this point in the history
  • Loading branch information
yuriescl committed Aug 31, 2023
1 parent fb2af83 commit 6a0d9b0
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
4 changes: 3 additions & 1 deletion docs/sep-24.rst
Original file line number Diff line number Diff line change
Expand Up @@ -406,7 +406,9 @@ Create a file for the template you'd like to extend or replace. In this guide we
Polaris provides two ``block`` tags that are intentionally left empty for anchors to extend: ``extra_head`` and ``extra_body``. These blocks should be used if you'll looking to add additional CSS or JavaScript files to any of your templates.

You are also allowed to extend any of the blocks actually implemented by Polaris, such as ``header``, ``content``, and ``footer``. Note that ``header`` contains ``extra_header`` and ``body`` contains ``extra_body``.
In case you want to override Polaris's JavaScript `<script>` tags, there's also a ``body_scripts`` block.

You are also allowed to extend any of the blocks actually implemented by Polaris, such as ``header``, ``content``, and ``footer``. Note that ``header`` contains ``extra_header``, and ``body`` contains ``extra_body`` and ``body_scripts``.

Lets add Google Analytics to our base template.

Expand Down
2 changes: 2 additions & 0 deletions polaris/templates/polaris/base.html
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@
{% endblock %}
</div>

{% block "body_scripts" %}
<script type="text/javascript" src="{% static 'polaris/scripts/number.js' %}"></script>
<script type="text/javascript" src="{% static 'polaris/scripts/styleHelpers.js' %}"></script>
<script type="text/javascript" src="{% static 'polaris/scripts/disableSubmitOnClick.js' %}"></script>
Expand Down Expand Up @@ -91,5 +92,6 @@
sessionOffset: {{ current_offset|default:0 }}
});
</script>
{% endblock "body_scripts" %}
</body>
</html>

0 comments on commit 6a0d9b0

Please sign in to comment.