{% macro action(action_element) -%}
{% if action_element['type'] == 4 %}
{{ action_element['html'] }}
{% else %}
<a title="{{ action_element['label'] }}" class="{{ action_element['class'] }}{% if action_element['disabled'] %} disabled{% endif %}" href="{{ action_element['url'] }}">{% if action_element['icon']  %}<i class="{{ action_element['icon'] }}"></i>{% if not action_element['only_icon'] %}&nbsp;{% endif %}{% endif %}{% if action_element['label'] and not action_element['only_icon'] %}{{ action_element['label'] }}{% endif %}</a>
{% endif %}
{%- endmacro %}

{% macro confirm_action(action_element) -%}
{% if action_element['type'] == 4 %}
{{ action_element['html'] }}
{% else %}
<a title="{{ action_element['label'] }}" class="{{ action_element['class'] }}{% if action_element['disabled'] %} disabled{% endif %}" onclick="if (confirm('{{ action_element['confirm_message'] }}')) { var f = document.createElement('form'); f.style.display = 'none'; this.parentNode.appendChild(f); f.method = 'post'; f.action = this.href;var m = document.createElement('input'); m.setAttribute('type', 'hidden'); m.setAttribute('name', 'method'); m.setAttribute('value', 'delete'); f.appendChild(m);var m = document.createElement('input'); m.setAttribute('type', 'hidden'); m.setAttribute('name', 'csrf_token'); m.setAttribute('value', '{{ action_element['form'].csrf_token.current_token }}'); f.appendChild(m);f.submit(); };return false;" href="{{ action_element['url'] }}">{% if action_element['icon']  %}<i class="{{ action_element['icon'] }}"></i>{% if not action_element['only_icon'] %}&nbsp;{% endif %}{% endif %}{% if action_element['label'] and not action_element['only_icon'] %}{{ action_element['label'] }}{% endif %}</a>
{% endif %}
{%- endmacro %}