X-Git-Url: https://vcs.fsf.org/?a=blobdiff_plain;f=mediagoblin%2Ftemplates%2Fmediagoblin%2Futils%2Fwtforms.html;h=58ecb8e092f01df9cac725aed9dac7733396bc78;hb=dc0b39b74741e7f4a7ba975c7ee98953bbf38816;hp=155569366f4abb813d0a274dd948abfa5b7cc593;hpb=76c9ea6b5fbdd1311b926b53b8b2c8afca9a69df;p=mediagoblin.git diff --git a/mediagoblin/templates/mediagoblin/utils/wtforms.html b/mediagoblin/templates/mediagoblin/utils/wtforms.html index 15556936..58ecb8e0 100644 --- a/mediagoblin/templates/mediagoblin/utils/wtforms.html +++ b/mediagoblin/templates/mediagoblin/utils/wtforms.html @@ -1,6 +1,6 @@ {# # GNU MediaGoblin -- federated, autonomous media hosting -# Copyright (C) 2011 Free Software Foundation, Inc +# Copyright (C) 2011, 2012 MediaGoblin contributors. See AUTHORS. # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by @@ -15,10 +15,37 @@ # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see . #} + +{# Generically render a field #} +{% macro render_field_div(field) %} + {% if field.label.text -%} +

+ {%- endif %} +
+ {{ field }} + {%- if field.errors -%} + {% for error in field.errors %} +

{{ _(error) }}

+ {% endfor %} + {%- endif %} + {% if field.description -%} +

{{ _(field.description)|safe }}

+ {%- endif %} +
+{%- endmacro %} + +{# Auto-render a form as a series of divs #} +{% macro render_divs(form) -%} + {% for field in form %} + {{ render_field_div(field) }} + {% endfor %} +{%- endmacro %} + +{# Auto-render a form as a table #} {% macro render_table(form) -%} {% for field in form %} - {{field.label}} + {{ _(field.label.text) }} {{field}} {% if field.errors %}