From b22a77f35a4a966dc686e8681753cd54cbb91a16 Mon Sep 17 00:00:00 2001 From: Mathieu Leplatre Date: Thu, 28 Sep 2023 13:18:44 +0200 Subject: [PATCH 1/4] Fix #1522: fix attribute error if css is str --- sphinx_rtd_theme/layout.html | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/sphinx_rtd_theme/layout.html b/sphinx_rtd_theme/layout.html index f3de11ad0..2778a1922 100644 --- a/sphinx_rtd_theme/layout.html +++ b/sphinx_rtd_theme/layout.html @@ -29,11 +29,19 @@ {%- endif %} {%- for css in css_files %} - {{ css_tag(css) }} + {% if css|attr("filename") -%} + {{ css_tag(css) }} + {%- else -%} + + {%- endif %} {%- endfor %} {%- for cssfile in extra_css_files %} - {{ css_tag(cssfile) }} + {% if css|attr("filename") -%} + {{ css_tag(css) }} + {%- else -%} + + {%- endif %} {%- endfor -%} {#- FAVICON From 82ee56f89cec921fdb07b7ef8fff6c8306e83634 Mon Sep 17 00:00:00 2001 From: Manuel Kaufmann Date: Mon, 23 Oct 2023 17:28:30 +0200 Subject: [PATCH 2/4] Revert "Fix #1522: fix attribute error if css is str" This reverts commit b22a77f35a4a966dc686e8681753cd54cbb91a16. --- sphinx_rtd_theme/layout.html | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/sphinx_rtd_theme/layout.html b/sphinx_rtd_theme/layout.html index 2778a1922..f3de11ad0 100644 --- a/sphinx_rtd_theme/layout.html +++ b/sphinx_rtd_theme/layout.html @@ -29,19 +29,11 @@ {%- endif %} {%- for css in css_files %} - {% if css|attr("filename") -%} - {{ css_tag(css) }} - {%- else -%} - - {%- endif %} + {{ css_tag(css) }} {%- endfor %} {%- for cssfile in extra_css_files %} - {% if css|attr("filename") -%} - {{ css_tag(css) }} - {%- else -%} - - {%- endif %} + {{ css_tag(cssfile) }} {%- endfor -%} {#- FAVICON From c4edd8b0673b40b7b635d7e775165a2c0731685c Mon Sep 17 00:00:00 2001 From: Manuel Kaufmann Date: Mon, 23 Oct 2023 17:28:46 +0200 Subject: [PATCH 3/4] Use `css_tag` only for standard CSS files from Sphinx ... and keep using the custom `link` HTML tag for CSS files included via the HTML theme option `extra_css_files`. --- sphinx_rtd_theme/layout.html | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/sphinx_rtd_theme/layout.html b/sphinx_rtd_theme/layout.html index f3de11ad0..ec4981099 100644 --- a/sphinx_rtd_theme/layout.html +++ b/sphinx_rtd_theme/layout.html @@ -32,8 +32,9 @@ {{ css_tag(css) }} {%- endfor %} + {# "extra_css_files" is a theme option and it's always a string #} {%- for cssfile in extra_css_files %} - {{ css_tag(cssfile) }} + {%- endfor -%} {#- FAVICON From 94f173b8ffb0469cc9b29736ca0a73e93d8d5109 Mon Sep 17 00:00:00 2001 From: Anthony Johnson Date: Mon, 23 Oct 2023 13:27:37 -0700 Subject: [PATCH 4/4] Normalize template variables --- sphinx_rtd_theme/layout.html | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/sphinx_rtd_theme/layout.html b/sphinx_rtd_theme/layout.html index ec4981099..bf2c52733 100644 --- a/sphinx_rtd_theme/layout.html +++ b/sphinx_rtd_theme/layout.html @@ -28,13 +28,13 @@ {%- endif %} - {%- for css in css_files %} - {{ css_tag(css) }} + {%- for css_file in css_files %} + {{ css_tag(css_file) }} {%- endfor %} {# "extra_css_files" is a theme option and it's always a string #} - {%- for cssfile in extra_css_files %} - + {%- for css_file in extra_css_files %} + {%- endfor -%} {#- FAVICON