From 75e79c30521ae3bde8cef1bddc64c0ac8e1fac8e Mon Sep 17 00:00:00 2001 From: Joshua Bussdieker Date: Wed, 4 Sep 2024 23:28:42 -0800 Subject: [PATCH] Support bootswatch_theme as parameter to load_css --- flask_bootstrap/__init__.py | 5 +++-- tests/test_bootstrap4/test_bootstrap.py | 6 ++++++ 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/flask_bootstrap/__init__.py b/flask_bootstrap/__init__.py index a207af74..3aaec82e 100644 --- a/flask_bootstrap/__init__.py +++ b/flask_bootstrap/__init__.py @@ -89,15 +89,16 @@ def init_app(self, app): 'row row-cols-lg-auto g-3 align-items-center' ) # Bootstrap 5 only - def load_css(self, version=None, bootstrap_sri=None): + def load_css(self, version=None, bootstrap_sri=None, bootswatch_theme=None): """Load Bootstrap's css resources with given version. .. versionadded:: 0.1.0 :param version: The version of Bootstrap. + :param bootswatch_theme: Set the bootswatch theme at the request/session level. """ serve_local = current_app.config['BOOTSTRAP_SERVE_LOCAL'] - bootswatch_theme = current_app.config['BOOTSTRAP_BOOTSWATCH_THEME'] + bootswatch_theme = bootswatch_theme or current_app.config['BOOTSTRAP_BOOTSWATCH_THEME'] if version is None: version = self.bootstrap_version bootstrap_sri = self._get_sri('bootstrap_css', version, bootstrap_sri) diff --git a/tests/test_bootstrap4/test_bootstrap.py b/tests/test_bootstrap4/test_bootstrap.py index f4749faa..bcbe3d65 100644 --- a/tests/test_bootstrap4/test_bootstrap.py +++ b/tests/test_bootstrap4/test_bootstrap.py @@ -38,6 +38,12 @@ def test_load_css_with_default_versions(self, bootstrap): 'crossorigin="anonymous">' assert bootstrap_css in rv + def test_load_css_with_bootswatch_theme(self, bootstrap): + rv = bootstrap.load_css(bootswatch_theme="mist") + bootstrap_css = f'