Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
dyve committed Apr 22, 2024
1 parent a695cf3 commit 983e7dc
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
{% load django_bootstrap5 %}
{% load i18n %}
{% get_current_language as LANGUAGE_CODE %}
{% bootstrap_setting 'color_mode' as COLOR_MODE %}
{% bootstrap_setting "color_mode" as COLOR_MODE %}
{% bootstrap_setting "javascript_in_head" as BOOTSTRAP_JAVASCRIPT_IN_HEAD %}
<html lang="{{ LANGUAGE_CODE|default:'en_us' }}"{% if COLOR_MODE %} data-bs-theme="{{ COLOR_MODE }}"{% endif %}>
<head>

Expand All @@ -17,9 +18,7 @@
{% bootstrap_css %}

<!-- Bootstrap JavaScript if it is in head -->
{% if 'javascript_in_head'|bootstrap_setting %}
{% bootstrap_javascript %}
{% endif %}
{% if BOOTSTRAP_JAVASCRIPT_IN_HEAD %}{% bootstrap_javascript %}{% endif %}

{% block bootstrap5_extra_head %}{% endblock %}

Expand All @@ -31,9 +30,7 @@
{% block bootstrap5_after_content %}{% endblock %}

<!-- Bootstrap JavaScript if it is in body -->
{% if not 'javascript_in_head'|bootstrap_setting %}
{% bootstrap_javascript %}
{% endif %}
{% if not BOOTSTRAP_JAVASCRIPT_IN_HEAD %}{% bootstrap_javascript %}{% endif %}

{% block bootstrap5_extra_script %}{% endblock %}

Expand Down
13 changes: 10 additions & 3 deletions tests/test_bootstrap_css_and_js_tags.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,15 @@ def test_bootstrap_css_tag_with_theme(self):
self.expected_bootstrap_css + '<link rel="stylesheet" href="//example.com/theme.css">',
)

def test_bootstrap_setting_filter(self):
self.assertEqual(self.render('{{ "required_css_class"|bootstrap_setting }}'), "django_bootstrap5-req")
def test_bootstrap_setting_tag(self):
self.assertEqual(
self.render('{% if "javascript_in_head"|bootstrap_setting %}head{% else %}body{% endif %}'), "head"
self.render('{% bootstrap_setting "required_css_class" %}'),
"django_bootstrap5-req",
)
self.assertEqual(
self.render(
'{% bootstrap_setting "javascript_in_head" as BOOTSTRAP_JAVASCRIPT_IN_HEAD %}'
+ "{% if BOOTSTRAP_JAVASCRIPT_IN_HEAD %}head{% else %}body{% endif %}"
),
"head",
)

0 comments on commit 983e7dc

Please sign in to comment.