{% macro print_message(message, category) %}
  {% if category == "error" %}
    {% set alert_class="alert-danger" %}
  {% elif category == "warning" %}
    {% set alert_class="alert-warning" %}
  {% elif category == "success" %}
    {% set alert_class="alert-success" %}
  {% else %}
    {% set alert_class="alert-info" %}
  {% endif %}

  <div class="alert {{ alert_class }}">{{ message }}</div>
{% endmacro %}

{% macro display_form_errors(form) %}
  {% for name, errors in form.errors.items() %}
    {% for error in errors %}
      {% if name is none %}
        {{ print_message(error, "error") }}
      {% else %}
        {{ print_message(form[name].label ~ ": " ~ error, "error") }}
      {% endif %}
    {% endfor %}
  {% endfor %}
{% endmacro %}

{% macro oauth_scope_desc(scopes) %}
  <ul>
    {% for scope in scopes %}
      <li>{{ scope.name }}: {{ scope.description }}</li>
    {% endfor %}
  </ul>
{% endmacro %}
