File tree Expand file tree Collapse file tree 2 files changed +33
-31
lines changed Expand file tree Collapse file tree 2 files changed +33
-31
lines changed Original file line number Diff line number Diff line change 1+ {# Macro for creating navigation links #}
2+ {% macro render_navigation(pagination, endpoint) %}
3+ < div >
4+ {% for page in pagination.iter_pages() %}
5+ {% if page %}
6+ {% if page != pagination.page %}
7+ < a href ="{{ url_for(endpoint, page=page) }} "> {{ page }}</ a >
8+ {% else %}
9+ < strong > {{ page }}</ strong >
10+ {% endif %}
11+ {% else %}
12+ < span > nothing to show</ span >
13+ {% endif %}
14+ {% endfor %}
15+ </ div >
16+ {% endmacro %}
17+
18+ {# Example macro for rendering fields #}
19+ {% macro render_field(field) %}
20+ < div class ="form_field ">
21+ {% if field.errors %}
22+ {% set css_class = 'has_error ' + kwargs.pop('class', '') %}
23+ {{ field.label }}{{ field(class=css_class, **kwargs) }}{% if field.flags.required %}*{% endif %}
24+ < ul class ="errors "> {% for error in field.errors %}
25+ < li > {{ error|e }}</ li > {% endfor %}</ ul >
26+ {% else %}
27+ {{ field.label }}{{ field(**kwargs) }}{% if field.flags.required %}*{% endif %}
28+ {% endif %}
29+ </ div >
30+ {% endmacro %}
Original file line number Diff line number Diff line change 11{% extends "layout.html" %}
2-
3- {# Macro for creating navigation links #}
4- {% macro render_navigation(pagination, endpoint) %}
5- < div >
6- {% for page in pagination.iter_pages() %}
7- {% if page %}
8- {% if page != pagination.page %}
9- < a href ="{{ url_for(endpoint, page=page) }} "> {{ page }}</ a >
10- {% else %}
11- < strong > {{ page }}</ strong >
12- {% endif %}
13- {% else %}
14- < span > nothing to show</ span >
15- {% endif %}
16- {% endfor %}
17- </ div >
18- {% endmacro %}
19-
20- {% macro with_errors(field) %}
21- < div class ="form_field ">
22- {% if field.errors %}
23- {% set css_class = 'has_error ' + kwargs.pop('class', '') %}
24- {{ field.label }}{{ field(class=css_class, **kwargs) }}{% if field.flags.required %}*{% endif %}
25- < ul class ="errors "> {% for error in field.errors %}
26- < li > {{ error|e }}</ li > {% endfor %}</ ul >
27- {% else %}
28- {{ field.label }}{{ field(**kwargs) }}{% if field.flags.required %}*{% endif %}
29- {% endif %}
30- </ div >
31- {% endmacro %}
2+ {% from "_formhelpers.html" import render_field %}
3+ {% from "_formhelpers.html" import render_navigation %}
324
335{% block body %}
346
6032 < div >
6133 < form method ="POST " action ="{{ url_for( "pagination ") }}">
6234 {% for field in form %}
63- {{ with_errors (field, style='font-weight: bold') }}
35+ {{ render_field (field, style='font-weight: bold') }}
6436 {% endfor %}
6537 < input type ="submit " value ="Create ">
6638 </ form >
You can’t perform that action at this time.
0 commit comments