django-cms / djangocms-icon

django CMS Icon adds capabilities to implement Font or SVG icons as plugins into your project.
https://www.django-cms.org
Other
18 stars 18 forks source link

Icon is not displayed in django_bootstrap4_link #32

Closed atlonxp closed 4 years ago

atlonxp commented 4 years ago

icon class is not rendered correctly.

<i class="" aria-hidden="true"></i>

Based on my investigation, the problem is caused when passing a parameter instance.icon_left or instance.icon_right from templates/djangocms_bootstrap4/link/default/link.html to templates/djangocms_icon/includes/icon.html

{% with icon_class=instance.icon_left instance=instance.icon_left %}{% include "djangocms_icon/includes/icon.html" %}{% endwith %}

<i class="{{ instance.icon }}...</i>

The easy is to create a custom template for templates/djangocms_icon/includes/icon.html, as follows

{% load cms_tags %}<i class="{% if icon_class %}{{ icon_class }}{% else %}{{ instance.icon }}{% endif %}{% if instance.attributes.class %} {{ instance.attributes.class }}{% endif %}" aria-hidden="true"{% for key, value in instance.attributes.items %}{% if key != 'class' %}{{ key }}="{{ value }}" {% endif %}{% endfor %}></i>

FinalAngel commented 4 years ago

@atlonxp I think this should be fixed in djangocms-bootstrap4 itself, either by providing the correct contextual value or an alternative template. Can you open it there with a reference to this issue?