From c79364a7e0af950022cb4d2c0528e11beaccdbf8 Mon Sep 17 00:00:00 2001 From: squidfunk Date: Sat, 16 Aug 2025 11:11:40 +0200 Subject: [PATCH] Fixed last minijinja compat issues in templates --- material/templates/partials/content.html | 2 +- material/templates/partials/icons.html | 52 +++++++++++++----------- material/templates/partials/social.html | 12 +++++- src/templates/partials/content.html | 2 +- src/templates/partials/icons.html | 52 +++++++++++++----------- src/templates/partials/social.html | 23 ++++++++++- 6 files changed, 89 insertions(+), 54 deletions(-) diff --git a/material/templates/partials/content.html b/material/templates/partials/content.html index ee069864d..0cb0a6bd5 100644 --- a/material/templates/partials/content.html +++ b/material/templates/partials/content.html @@ -3,7 +3,7 @@ -#} {% include "partials/tags.html" %} {% include "partials/actions.html" %} -{% if "\x3ch1" not in page.content %} +{% if "\u003ch1" not in page.content %}

{{ page.title | d(config.site_name, true)}}

{% endif %} {{ page.content }} diff --git a/material/templates/partials/icons.html b/material/templates/partials/icons.html index 7d3aaded0..3dc3cdaf8 100644 --- a/material/templates/partials/icons.html +++ b/material/templates/partials/icons.html @@ -2,21 +2,23 @@ This file was automatically generated - do not edit -#} {% if config.theme.icon.admonition %} - {% set _ = namespace(style = "\x3cstyle\x3e:root{") %} + {% set _ = namespace(style = "\u003cstyle\u003e:root{") %} {% for type, icon in config.theme.icon.admonition | items %} - {% import ".icons/" ~ icon ~ ".svg" as icon %} - {% set _.style = _.style ~ - "--md-admonition-icon--" ~ type ~ ":" ~ - "url('data:image/svg+xml;charset=utf-8," ~ - icon | replace("\n", "") | urlencode ~ - "');" - %} + {% if type and icon %} + {% import ".icons/" ~ icon ~ ".svg" as icon %} + {% set _.style = _.style ~ + "--md-admonition-icon--" ~ type ~ ":" ~ + "url('data:image/svg+xml;charset=utf-8," ~ + icon | replace("\n", "") | urlencode ~ + "');" + %} + {% endif %} {% endfor %} - {% set _.style = _.style ~ "}\x3c/style\x3e" %} + {% set _.style = _.style ~ "}\u003c/style\u003e" %} {{ _.style }} {% endif %} {% if config.theme.icon.annotation %} - {% set _ = namespace(style = "\x3cstyle\x3e:root{") %} + {% set _ = namespace(style = "\u003cstyle\u003e:root{") %} {% import ".icons/" ~ config.theme.icon.annotation ~ ".svg" as icon %} {% set _.style = _.style ~ "--md-annotation-icon:" ~ @@ -24,25 +26,27 @@ icon | replace("\n", "") | urlencode ~ "');" %} - {% set _.style = _.style ~ "}\x3c/style\x3e" %} + {% set _.style = _.style ~ "}\u003c/style\u003e" %} {{ _.style }} {% endif %} {% if config.theme.icon.tag %} - {% set _ = namespace(style = "\x3cstyle\x3e:root{") %} + {% set _ = namespace(style = "\u003cstyle\u003e:root{") %} {% for type, icon in config.theme.icon.tag | items %} - {% import ".icons/" ~ icon ~ ".svg" as icon %} - {% if type != "default" %} - {% set modifier = ".md-tag--" ~ type %} + {% if type and icon %} + {% import ".icons/" ~ icon ~ ".svg" as icon %} + {% if type != "default" %} + {% set modifier = ".md-tag--" ~ type %} + {% endif %} + {% set _.style = _.style ~ + ".md-tag" ~ modifier ~ "{" ~ + "--md-tag-icon:" ~ + "url('data:image/svg+xml;charset=utf-8," ~ + icon | replace("\n", "") | urlencode ~ + "');" ~ + "}" + %} {% endif %} - {% set _.style = _.style ~ - ".md-tag" ~ modifier ~ "{" ~ - "--md-tag-icon:" ~ - "url('data:image/svg+xml;charset=utf-8," ~ - icon | replace("\n", "") | urlencode ~ - "');" ~ - "}" - %} {% endfor %} - {% set _.style = _.style ~ "}\x3c/style\x3e" %} + {% set _.style = _.style ~ "}\u003c/style\u003e" %} {{ _.style }} {% endif %} diff --git a/material/templates/partials/social.html b/material/templates/partials/social.html index 3263c1a3d..3e1040f02 100644 --- a/material/templates/partials/social.html +++ b/material/templates/partials/social.html @@ -1,6 +1,14 @@ {#- This file was automatically generated - do not edit -#} +{% macro split_and_get(value, sep, index) %} + {%- if value.split is defined -%} + {%- set parts = value.split(sep) -%} + {%- else -%} + {%- set parts = value | split(sep) -%} + {%- endif -%} + {{- parts[index] -}} +{% endmacro %}
{% for social in config.extra.social %} {% set rel = "noopener" %} @@ -9,8 +17,8 @@ {% endif %} {% set title = social.name %} {% if not title and "//" in social.link %} - {% set (_, url) = social.link.split("//") %} - {% set title = url.split("/") | first %} + {% set url = split_and_get(social.link, "//", 1) %} + {% set title = split_and_get(url, "/", 0) %} {% endif %} {% include ".icons/" ~ social.icon ~ ".svg" %} diff --git a/src/templates/partials/content.html b/src/templates/partials/content.html index d8c20eb78..e2aafb255 100644 --- a/src/templates/partials/content.html +++ b/src/templates/partials/content.html @@ -30,7 +30,7 @@ Hack: check whether the content contains a h1 headline. If it doesn't, the page title (or respectively site name) is used as the main headline. --> -{% if "\x3ch1" not in page.content %} +{% if "\u003ch1" not in page.content %}

{{ page.title | d(config.site_name, true)}}

{% endif %} diff --git a/src/templates/partials/icons.html b/src/templates/partials/icons.html index c18cea364..a03ab9996 100644 --- a/src/templates/partials/icons.html +++ b/src/templates/partials/icons.html @@ -22,23 +22,25 @@ {% if config.theme.icon.admonition %} - {% set _ = namespace(style = "\x3cstyle\x3e:root{") %} + {% set _ = namespace(style = "\u003cstyle\u003e:root{") %} {% for type, icon in config.theme.icon.admonition | items %} - {% import ".icons/" ~ icon ~ ".svg" as icon %} - {% set _.style = _.style ~ - "--md-admonition-icon--" ~ type ~ ":" ~ - "url('data:image/svg+xml;charset=utf-8," ~ - icon | replace("\n", "") | urlencode ~ - "');" - %} + {% if type and icon %} + {% import ".icons/" ~ icon ~ ".svg" as icon %} + {% set _.style = _.style ~ + "--md-admonition-icon--" ~ type ~ ":" ~ + "url('data:image/svg+xml;charset=utf-8," ~ + icon | replace("\n", "") | urlencode ~ + "');" + %} + {% endif %} {% endfor %} - {% set _.style = _.style ~ "}\x3c/style\x3e" %} + {% set _.style = _.style ~ "}\u003c/style\u003e" %} {{ _.style }} {% endif %} {% if config.theme.icon.annotation %} - {% set _ = namespace(style = "\x3cstyle\x3e:root{") %} + {% set _ = namespace(style = "\u003cstyle\u003e:root{") %} {% import ".icons/" ~ config.theme.icon.annotation ~ ".svg" as icon %} {% set _.style = _.style ~ "--md-annotation-icon:" ~ @@ -46,27 +48,29 @@ icon | replace("\n", "") | urlencode ~ "');" %} - {% set _.style = _.style ~ "}\x3c/style\x3e" %} + {% set _.style = _.style ~ "}\u003c/style\u003e" %} {{ _.style }} {% endif %} {% if config.theme.icon.tag %} - {% set _ = namespace(style = "\x3cstyle\x3e:root{") %} + {% set _ = namespace(style = "\u003cstyle\u003e:root{") %} {% for type, icon in config.theme.icon.tag | items %} - {% import ".icons/" ~ icon ~ ".svg" as icon %} - {% if type != "default" %} - {% set modifier = ".md-tag--" ~ type %} + {% if type and icon %} + {% import ".icons/" ~ icon ~ ".svg" as icon %} + {% if type != "default" %} + {% set modifier = ".md-tag--" ~ type %} + {% endif %} + {% set _.style = _.style ~ + ".md-tag" ~ modifier ~ "{" ~ + "--md-tag-icon:" ~ + "url('data:image/svg+xml;charset=utf-8," ~ + icon | replace("\n", "") | urlencode ~ + "');" ~ + "}" + %} {% endif %} - {% set _.style = _.style ~ - ".md-tag" ~ modifier ~ "{" ~ - "--md-tag-icon:" ~ - "url('data:image/svg+xml;charset=utf-8," ~ - icon | replace("\n", "") | urlencode ~ - "');" ~ - "}" - %} {% endfor %} - {% set _.style = _.style ~ "}\x3c/style\x3e" %} + {% set _.style = _.style ~ "}\u003c/style\u003e" %} {{ _.style }} {% endif %} diff --git a/src/templates/partials/social.html b/src/templates/partials/social.html index f9be14156..2a768879b 100644 --- a/src/templates/partials/social.html +++ b/src/templates/partials/social.html @@ -20,6 +20,25 @@ IN THE SOFTWARE. --> + +{% macro split_and_get(value, sep, index) %} + {%- if value.split is defined -%} + {%- set parts = value.split(sep) -%} + {%- else -%} + {%- set parts = value | split(sep) -%} + {%- endif -%} + {{- parts[index] -}} +{% endmacro %} + + +
{% for social in config.extra.social %} @@ -33,8 +52,8 @@ {% set title = social.name %} {% if not title and "//" in social.link %} - {% set (_, url) = social.link.split("//") %} - {% set title = url.split("/") | first %} + {% set url = split_and_get(social.link, "//", 1) %} + {% set title = split_and_get(url, "/", 0) %} {% endif %}