1
0
mirror of https://github.com/moepman/bk-dss synced 2024-12-22 12:44:27 +01:00

Render buttons using a macro.

This commit is contained in:
Markus 2016-03-21 23:16:50 +01:00
parent 3d82ce657a
commit 59962f53a1
4 changed files with 11 additions and 7 deletions

View File

@ -1,3 +1,7 @@
{% macro render_field(field) %} {% macro render_field(field) %}
<div class="form-group {% if field.errors %}has-error{% endif %}">{{ field.label(class_="control-label col-sm-2") }}<div class="col-sm-4">{{ field(class_="form-control") }}</div>{% for error in field.errors %}[ {{ error }} ]{% endfor %}</div> <div class="form-group {% if field.errors %}has-error{% endif %}">{{ field.label(class_="control-label col-sm-3") }}<div class="col-sm-5">{{ field(class_="form-control") }}</div>{% for error in field.errors %}[ {{ error }} ]{% endfor %}</div>
{%- endmacro %}
{% macro render_button(button) %}
<div class="form-group"><div class="col-sm-offset-3 col-sm-5">{{ button(class_="btn btn-primary") }}</div></div>
{%- endmacro %} {%- endmacro %}

View File

@ -1,4 +1,4 @@
{% from "_helpers.html" import render_field %} {% from "_helpers.html" import render_button, render_field %}
{% extends "_base.html" %} {% extends "_base.html" %}
{% block content %} {% block content %}
<div class="page-header"> <div class="page-header">
@ -12,6 +12,6 @@
{{ render_field(form.gn) }} {{ render_field(form.gn) }}
{{ render_field(form.pwd1) }} {{ render_field(form.pwd1) }}
{{ render_field(form.pwd2) }} {{ render_field(form.pwd2) }}
<div class="form-group"><div class="col-sm-offset-2 col-sm-10">{{ form.submit(class_="btn btn-primary") }}</div></div> {{ render_button(form.submit) }}
</form> </form>
{% endblock %} {% endblock %}

View File

@ -1,4 +1,4 @@
{% from "_helpers.html" import render_field %} {% from "_helpers.html" import render_button, render_field %}
{% extends "_base.html" %} {% extends "_base.html" %}
{% block content %} {% block content %}
<div class="page-header"> <div class="page-header">
@ -9,6 +9,6 @@
{{ render_field(form.user) }} {{ render_field(form.user) }}
{{ render_field(form.pwd1) }} {{ render_field(form.pwd1) }}
{{ render_field(form.pwd2) }} {{ render_field(form.pwd2) }}
<div class="form-group"><div class="col-sm-offset-2 col-sm-10">{{ form.submit(class_="btn btn-primary") }}</div></div> {{ render_button(form.submit) }}
</form> </form>
{% endblock %} {% endblock %}

View File

@ -1,4 +1,4 @@
{% from "_helpers.html" import render_field %} {% from "_helpers.html" import render_button, render_field %}
{% extends "_base.html" %} {% extends "_base.html" %}
{% block content %} {% block content %}
<div class="page-header"> <div class="page-header">
@ -8,6 +8,6 @@
{{ form.hidden_tag() }} {{ form.hidden_tag() }}
{{ render_field(form.user) }} {{ render_field(form.user) }}
{{ render_field(form.pswd) }} {{ render_field(form.pswd) }}
<div class="form-group"><div class="col-sm-offset-2 col-sm-10">{{ form.submit(class_="btn btn-primary") }}</div></div> {{ render_button(form.submit) }}
</form> </form>
{% endblock %} {% endblock %}