Move badge code to separate file

This commit is contained in:
2020-05-13 10:59:56 -05:00
parent c518f558e5
commit 58cb1ec15d
2 changed files with 28 additions and 21 deletions

20
_includes/badge.html Normal file
View File

@ -0,0 +1,20 @@
{% if include.link %}
<a
href="{{ link }}" class="badge badge-{{ include.color | default: "info" }}"
{% if include.tooltip %}
data-toggle="tooltip"
title="{{ include.tooltip }}"><i class="{{ include.icon | default: "far fa-question-circle"}}"></i> {{ include.text }}
{% else %}><i class="{{ include.icon | default: "fas fa-external-link-alt"}}"></i> {{ include.text }}{% endif %}
</a>
{% else %}
<span
class="badge badge-{{ include.color | default: "info" }}"
{% if include.tooltip %}
data-toggle="tooltip"
title="{{ include.tooltip }}"
> <i class="{{ include.icon | default: "far fa-question-circle"}}"></i> {{include.text}}
{% else %}
> {% if include.icon %}<i class="{{ include.icon }}"></i>{% endif %} {{include.text}}
{% endif %}
</span>
{% endif %}

View File

@ -45,7 +45,7 @@
{% assign label_data = label | split:"::" %}
{% for label_attr in label_data %}
{% assign attr = label_attr | split:"==" %}
{% if attr[0] == "color" }
{% if attr[0] == "color" %}
{% assign color = attr[1] %}
{% elsif attr[0] == "link" %}
{% assign link = attr[1] %}
@ -57,26 +57,13 @@
{% assign tooltip = attr[1] %}
{% endif %}
{% endfor %}
{% if link %}
<a
href="{{ link }}" class="badge badge-{{ color | default: "info" }}"
{% if tooltip %}
data-toggle="tooltip"
title="{{ tooltip }}"><i class="{{ icon | default: "far fa-question-circle"}}"></i> {{ text }}
{% else %}><i class="{{ icon | default: "fas fa-external-link-alt"}}"></i> {{ text }}{% endif %}
</a>
{% else %}
<span
class="badge badge-{{ color | default: "info" }}"
{% if tooltip %}
data-toggle="tooltip"
title="{{ tooltip }}"
> <i class="{{ icon | default: "far fa-question-circle"}}"> {{text}}
{% else %}
> {% if icon %}<i class="{{ icon }}"></i>{% endif %} {{text}}
{% endif %}
</span>
{% endif %}
{% include badge.html
link=link
color=color
text=text
icon=icon
tooltip=tooltip
%}
{% endfor %}
{% endif %}
</p>