From: Christopher Allan Webber Date: Sat, 25 Jun 2011 04:46:11 +0000 (-0500) Subject: Separates out the field rendering part from the whole form rendering macro X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=528f9acd23d1c474a6092f67c4187d9f074de3a2;p=mediagoblin.git Separates out the field rendering part from the whole form rendering macro Also adds a textarea-specific version that renders rows and cols as part of the input. --- diff --git a/mediagoblin/templates/mediagoblin/utils/wtforms.html b/mediagoblin/templates/mediagoblin/utils/wtforms.html index 9adf8e53..1d2f8619 100644 --- a/mediagoblin/templates/mediagoblin/utils/wtforms.html +++ b/mediagoblin/templates/mediagoblin/utils/wtforms.html @@ -16,23 +16,47 @@ # along with this program. If not, see . #} +{# Generically render a field #} +{% macro render_field_div(field) %} +
+
{{ field.label }}
+ {% if field.description -%} +
{{ field.description }}
+ {%- endif %} +
{{ field }}
+ {%- if field.errors -%} + {% for error in field.errors %} +
+ {{ error }} +
+ {% endfor %} + {%- endif %} +
+{%- endmacro %} + +{# Generically render a textarea + # ... mostly the same thing except it includes rows and cols #} +{% macro render_textarea_div(field, rows=8, cols=20) %} +
+
{{ field.label }}
+ {% if field.description -%} +
{{ field.description }}
+ {%- endif %} +
{{ field(rows=rows, cols=cols) }}
+ {%- if field.errors -%} + {% for error in field.errors %} +
+ {{ error }} +
+ {% endfor %} + {%- endif %} +
+{%- endmacro %} + {# Auto-render a form as a series of divs #} {% macro render_divs(form) -%} {% for field in form %} -
-
{{ field.label }}
- {% if field.description -%} -
{{ field.description }}
- {%- endif %} -
{{ field }}
- {%- if field.errors -%} - {% for error in field.errors %} -
- {{ error }} -
- {% endfor %} - {%- endif %} -
+ {{ render_field_div(field) }} {% endfor %} {%- endmacro %}