adding new form
Gitea Actions Demo / Explore-Gitea-Actions (push) Has been cancelled

This commit is contained in:
Pierre Geeraert
2025-07-29 09:39:41 +01:00
parent 2366d0c2a8
commit bccd344aa7
9310 changed files with 1330402 additions and 1 deletions
@@ -0,0 +1,28 @@
from django.utils.safestring import mark_safe
from django.utils.translation import gettext as _
from bootstrap5.utils import render_tag
from .text import text_value
def render_alert(content, alert_type=None, dismissible=True):
"""Render a Bootstrap alert."""
button = ""
if not alert_type:
alert_type = "info"
css_classes = ["alert", "alert-" + text_value(alert_type)]
if dismissible:
css_classes.append("alert-dismissible")
close = _("close")
button = (
'<button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="{close}"></button>'
).format(close=close)
button_placeholder = "__BUTTON__"
return mark_safe(
render_tag(
"div",
attrs={"class": " ".join(css_classes), "role": "alert"},
content=mark_safe(button_placeholder) + text_value(content),
).replace(button_placeholder, button)
)