{% macro render_field(field) %}
    {% if field.errors %}
    <li class="error">
    {% else %}
    <li>
    {% endif %}
        <label>{{ field.label.text }}{% if field.flags.required %} <span class="required">(required)</span>{% endif %}</label>
        {{ field(**kwargs)|safe }}
        {% if field.errors %}
            <span class="field-error">{{ field.errors|join("<br />") }}</span>
        {% endif %}
    </li>
{% endmacro %}
