Skip to content

Commit

Permalink
Prep django5.0: Replaces format_html with mark_safe
Browse files Browse the repository at this point in the history
  • Loading branch information
christianwgd committed Nov 16, 2023
1 parent e34fbbd commit 0719369
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions django_bootstrap_icons/templatetags/bootstrap_icons.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
# noinspection PyProtectedMember
from django.core.exceptions import ImproperlyConfigured
from django.template import Library
from django.utils.html import format_html
from django.utils.safestring import mark_safe

register = Library()

Expand Down Expand Up @@ -88,7 +88,7 @@ def custom_icon(icon_name, size=None, color=None, extra_classes=None):
content = parse(icon_path)
except FileNotFoundError:
return f"Icon <{icon_path}> does not exist"
return format_html(render_svg(content, size, color, extra_classes))
return mark_safe(render_svg(content, size, color, extra_classes))


def get_icon(icon_path, icon_name, size=None, color=None, extra_classes=None):
Expand Down Expand Up @@ -162,7 +162,7 @@ def bs_icon(icon_name, size=None, color=None, extra_classes=None):
icon_path = f'{base_url}icons/{icon_name}.svg'

svg = get_icon(icon_path, icon_name, size, color, extra_classes)
return format_html(svg)
return mark_safe(svg)


@register.simple_tag
Expand Down Expand Up @@ -195,4 +195,4 @@ def md_icon(icon_name, size=None, color=None, extra_classes=None):
icon_path = f'{base_url}svg/{icon_name}.svg'

svg = get_icon(icon_path, icon_name, size, color, extra_classes)
return format_html(svg)
return mark_safe(svg)

0 comments on commit 0719369

Please sign in to comment.