diff --git a/flask_bootstrap/__init__.py b/flask_bootstrap/__init__.py index a207af7..3aaec82 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 f4749fa..bcbe3d6 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'