summaryrefslogtreecommitdiffstats
path: root/ogcp/templates
diff options
context:
space:
mode:
authorJavier Sánchez Parra <jsanchez@soleta.eu>2022-03-25 11:19:53 +0100
committerJavier Sánchez Parra <jsanchez@soleta.eu>2022-03-25 12:08:39 +0100
commitd4e7a9f05bc45def5e5738ffd8d2391795311fd0 (patch)
tree15cdc6184ded6fba108c00de1f54d0e9f955e6ce /ogcp/templates
parent4f33ab1128886875346f316d3aeffb999d947281 (diff)
Replace " " with "_" in HTML scopes IDs
Otherwise, scopes with whitespaces in their names breaks the javascript code. From https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/id: --- Note: Technically, in HTML5, the value for an id attribute may contain any character, except whitespace characters. However, to avoid inadvertent errors, only ASCII letters, digits, '_', and '-' should be used and the value for an id attribute should start with a letter. For example, . has a special meaning in CSS (it acts as a class selector). Unless you are careful to escape it in the CSS, it won't be recognized as part of the value of an id attribute. It is easy to forget to do this, resulting in bugs in your code that could be hard to detect. ---
Diffstat (limited to 'ogcp/templates')
-rw-r--r--ogcp/templates/macros.html4
1 files changed, 2 insertions, 2 deletions
diff --git a/ogcp/templates/macros.html b/ogcp/templates/macros.html
index fed48a6..96561db 100644
--- a/ogcp/templates/macros.html
+++ b/ogcp/templates/macros.html
@@ -21,7 +21,7 @@
{% macro scopes_tree_collapse_level(scopes, i, parent_id, state) -%}
{% for scope in scopes %}
- <li id="{{ scope["name"]|replace(".", "_") }}_{{ scope["id"] }}" class="nav-item">
+ <li id="{{ scope["name"]|replace(".", "_")|replace(" ", "_") }}_{{ scope["id"] }}" class="nav-item">
{% if " ".join(scope["ip"]) %}
<input class="form-check-input" type="checkbox" form="scopesForm"
value="{{ " ".join(scope["ip"]) }}" {{ state }}
@@ -58,7 +58,7 @@
<div class="d-flex flex-wrap justify-content-center">
{% set max_clients = 50 %}
{% for name_id, ip in selected_clients[:max_clients] %}
- <div id="pill-{{ name_id|replace(".", "_") }}" class="badge badge-pill og-pill badge-light">
+ <div id="pill-{{ name_id|replace(".", "_")|replace(" ", "_") }}" class="badge badge-pill og-pill badge-light">
{{ name_id }}<br>{{ ip }}
</div>
{% if loop.last and (selected_clients|length > max_clients) %}