Skip to content

Instantly share code, notes, and snippets.

View dhhagan's full-sized avatar
🙀
Building @quant-aq

David H Hagan dhhagan

🙀
Building @quant-aq
View GitHub Profile
@dhhagan
dhhagan / gist:c36ce965a679e8889513
Last active September 12, 2015 12:51 — forked from maximebf/gist:3986659
Jinja2 macro to render WTForms fields with Twitter Bootstrap
{% macro form_field(field) -%}
{% set with_label = kwargs.pop('with_label', False) %}
{% set placeholder = '' %}
{% if not with_label %}
{% set placeholder = field.label.text %}
{% endif %}
<div class="control-group {% if field.errors %}error{% endif %}">
{% if with_label %}
<label for="{{ field.id }}" class="control-label">
{{ field.label.text }}{% if field.flags.required %} *{% endif %}: