macros.html 909 B

12345678910111213141516171819202122232425262728
  1. {# myapp/templates/macros.html #}
  2. <!-- Highlight the current tab -->
  3. {% macro nav_link(endpoint, text) %}
  4. {% if request.endpoint is not none %}
  5. {% if request.endpoint.endswith(endpoint) %}
  6. <a class="active teal item" href="{{ url_for(endpoint) }}">{{ text }}</a>
  7. {% else %}
  8. <a class="item" href="{{ url_for(endpoint) }}">{{ text }}</a>
  9. {% endif %}
  10. {% else %}
  11. <a class="item" href="{{ url_for(endpoint) }}">{{ text }}</a>
  12. {% endif %}
  13. {% endmacro %}
  14. <!-- Render a WTForm form's field (with it's possible associated errors) from a WTForms form -->
  15. {% macro render_field(field) %}
  16. <div class="field">
  17. {{ field(name_=field.name, id=field.name, placeholder=field.description, class_="field") }}
  18. </div>
  19. {% if field.errors %}
  20. <ul>
  21. {% for error in field.errors %}
  22. <li class="form-error">{{ error }}</li>
  23. {% endfor %}
  24. </ul>
  25. {% endif %}
  26. {% endmacro %}