{#
    Copyright (c) 2015 Chintalagiri Shashank
    Released under the MIT license
#}

{% macro render_field(field) -%}
    <div {% if field.errors %} class="error"{% endif %}>
        <label {% if field.errors %} class="error"{% endif %}><span>{{ field.label.text|safe }}</span>
            {% if field.flags.required %}<span class="right text-right"><small>Required</small></span>{% endif %}
            {{ field(**kwargs) }}
        </label>
        {% if field.errors %}
            {% for e in field.errors %}
                <small class="error">{{ e }}</small>
            {% endfor %}
        {% endif %}
    </div>
{% endmacro %}

{% macro render_clean_field(field) -%}
    <div {% if field.errors %} class="error"{% endif %}>
        {{ field(placeholder=field.label.text, **kwargs) }}
        {% if field.errors %}
            {% for e in field.errors %}
                <small class="error">{{ e }}</small>
            {% endfor %}
        {% endif %}
    </div>
{% endmacro %}

{% macro render_switch(field) -%}
    <div class="small-6 medium-6 large-4 columns small-text-center medium-text-center switch radius small">
        {{ field(**kwargs) }}
        <label for="{{ field.id }}"></label>
    </div>
    <div class="small-6 medium-6 large-8 columns small-text-left medium-text-left">
        <label>{{ field.label.text|safe }}</label>
    </div>
{% endmacro %}

{% macro render_compact_switch(field) -%}
    <label class="small-12 columns text-center">{{ field.label.text|safe }}</label>
    <div class="small-12 columns switch radius small">
        {{ field(**kwargs) }}
        <label for="{{ field.id }}"></label>
    </div>
{% endmacro %}

{% macro render_checkbox_button(field) -%}
    <div class="checkbox-button">
        <label>
            {{ field(hidden=True) }}
            <span>{{ field.label.text|upper }}</span>
        </label>
    </div>
{% endmacro %}
