move macros to new file

This commit is contained in:
Patrick Jentsch 2020-02-24 09:27:02 +01:00
parent c7254781d0
commit 31c958cb6f
15 changed files with 49 additions and 46 deletions

View File

@ -49,7 +49,7 @@
</div> </div>
</div> </div>
<div class="card-action right-align"> <div class="card-action right-align">
{{ submit_button(edit_user_form.submit) }} {{ macros.submit_button(edit_user_form.submit) }}
</div> </div>
</form> </form>
</div> </div>

View File

@ -59,7 +59,7 @@
</div> </div>
</div> </div>
<div class="card-action right-align"> <div class="card-action right-align">
{{ submit_button(login_form.submit) }} {{ macros.submit_button(login_form.submit) }}
</div> </div>
</form> </form>
</div> </div>

View File

@ -57,7 +57,7 @@
</div> </div>
</div> </div>
<div class="card-action right-align"> <div class="card-action right-align">
{{ submit_button(registration_form.submit) }} {{ macros.submit_button(registration_form.submit) }}
</div> </div>
</form> </form>
</div> </div>

View File

@ -27,7 +27,7 @@
</div> </div>
</div> </div>
<div class="card-action right-align"> <div class="card-action right-align">
{{ submit_button(reset_password_form.submit) }} {{ macros.submit_button(reset_password_form.submit) }}
</div> </div>
</form> </form>
</div> </div>

View File

@ -20,7 +20,7 @@
</div> </div>
</div> </div>
<div class="card-action right-align"> <div class="card-action right-align">
{{ submit_button(reset_password_request_form.submit) }} {{ macros.submit_button(reset_password_request_form.submit) }}
</div> </div>
</form> </form>
</div> </div>

View File

@ -41,7 +41,7 @@
</div> </div>
</div> </div>
<div class="card-action right-align"> <div class="card-action right-align">
{{ submit_button(add_corpus_form.submit) }} {{ macros.submit_button(add_corpus_form.submit) }}
</div> </div>
</form> </form>
</div> </div>

View File

@ -1,18 +1,5 @@
{% extends "nopaque.html.j2" %} {% extends "nopaque.html.j2" %}
{% macro render_field(field) %}
<div class="input-field">
<i class="prefix">{{ field.name[0:1]|upper }}</i>
{{ field.label }}
{{ field(data_length='255')|safe }}
</div>
{% if field.errors %}
{% for error in field.errors %}
<span class="helper-text red-text">{{ error }}</span>
{% endfor %}
{% endif %}
{% endmacro %}
{% block page_content %} {% block page_content %}
<div class="col s12 m4"> <div class="col s12 m4">
<h3>{{ corpus.title }}</h3> <h3>{{ corpus.title }}</h3>
@ -74,7 +61,7 @@
</div> </div>
</div> </div>
<div class="card-action right-align"> <div class="card-action right-align">
{{ submit_button(add_corpus_file_form.submit) }} {{ macros.submit_button(add_corpus_file_form.submit) }}
</div> </div>
</div> </div>
<br> <br>
@ -91,7 +78,7 @@
or field.name == "csrf_token" or field.name == "csrf_token"
or field.name == "title" or field.name == "title"
or field.name == "publishing_year") %} or field.name == "publishing_year") %}
{{ render_field(field)}} {{ macros.render_field(field)}}
{% endfor %} {% endfor %}
</div> </div>
</div> </div>

View File

@ -1,18 +1,5 @@
{% extends "nopaque.html.j2" %} {% extends "nopaque.html.j2" %}
{% macro render_field_with_value(field, corpus_file) %}
<div class="input-field">
<i class="prefix">{{ field.name[0:1]|upper }}</i>
{{ field.label }}
{{ field(value=corpus_file[field.name], data_length='255')| safe }}
</div>
{% if field.errors %}
{% for error in field.errors %}
<span class="helper-text red-text">{{ error }}</span>
{% endfor %}
{% endif %}
{% endmacro %}
{% block page_content %} {% block page_content %}
<div class="col s12 m4"> <div class="col s12 m4">
<h3 id="title">...</h3> <h3 id="title">...</h3>
@ -59,7 +46,7 @@
</div> </div>
</div> </div>
<div class="card-action right-align"> <div class="card-action right-align">
{{ submit_button(edit_corpus_file_form.submit) }} {{ macros.submit_button(edit_corpus_file_form.submit) }}
</div> </div>
</div> </div>
<br> <br>
@ -76,7 +63,7 @@
or field.name == "csrf_token" or field.name == "csrf_token"
or field.name == "title" or field.name == "title"
or field.name == "publishing_year") %} or field.name == "publishing_year") %}
{{ render_field_with_value(field, corpus_file)}} {{ macros.render_field_with_value(field, corpus_file)}}
{% endfor %} {% endfor %}
</div> </div>
</div> </div>

View File

@ -0,0 +1,31 @@
{% macro render_field(field) %}
<div class="input-field">
<i class="prefix">{{ field.name[0:1]|upper }}</i>
{{ field.label }}
{{ field(data_length='255')|safe }}
</div>
{% if field.errors %}
{% for error in field.errors %}
<span class="helper-text red-text">{{ error }}</span>
{% endfor %}
{% endif %}
{% endmacro %}
{% macro render_field_with_value(field, corpus_file) %}
<div class="input-field">
<i class="prefix">{{ field.name[0:1]|upper }}</i>
{{ field.label }}
{{ field(value=corpus_file[field.name], data_length='255')| safe }}
</div>
{% if field.errors %}
{% for error in field.errors %}
<span class="helper-text red-text">{{ error }}</span>
{% endfor %}
{% endif %}
{% endmacro %}
{% macro submit_button(input) %}
<button class="btn waves-effect waves-light" id="{{ input.id }}" name="{{ input.name }}" type="submit" value="{{ input.label.text }}">{{ input.label.text }}<i class="material-icons right">send</i></button>
{% endmacro %}

View File

@ -123,7 +123,7 @@
</div> </div>
</div> </div>
<div class="card-action right-align"> <div class="card-action right-align">
{{ submit_button(login_form.submit) }} {{ macros.submit_button(login_form.submit) }}
</div> </div>
</form> </form>
</div> </div>

View File

@ -1,6 +1,4 @@
{% macro submit_button(input) %} {% import "macros.jinja" as macros %}
<button class="btn waves-effect waves-light" id="{{ input.id }}" name="{{ input.name }}" type="submit" value="{{ input.label.text }}">{{ input.label.text }}<i class="material-icons right">send</i></button>
{% endmacro %}
<!DOCTYPE html> <!DOCTYPE html>
<html lang="en"> <html lang="en">

View File

@ -31,7 +31,7 @@
</div> </div>
</div> </div>
<div class="card-action right-align"> <div class="card-action right-align">
{{ submit_button(edit_general_settings_form.save_settings) }} {{ macros.submit_button(edit_general_settings_form.save_settings) }}
</div> </div>
</form> </form>
</div> </div>
@ -76,7 +76,7 @@
</div> </div>
</div> </div>
<div class="card-action right-align"> <div class="card-action right-align">
{{ submit_button(edit_password_form.save_password) }} {{ macros.submit_button(edit_password_form.save_password) }}
</div> </div>
</form> </form>
</div> </div>
@ -105,7 +105,7 @@
</div> </div>
</div> </div>
<div class="card-action right-align"> <div class="card-action right-align">
{{ submit_button(edit_email_form.save_email) }} {{ macros.submit_button(edit_email_form.save_email) }}
</div> </div>
</form> </form>
</div> </div>

View File

@ -110,7 +110,7 @@
</div> </div>
</div> </div>
<div class="card-action right-align"> <div class="card-action right-align">
{{ submit_button(add_job_form.submit) }} {{ macros.submit_button(add_job_form.submit) }}
</div> </div>
</form> </form>
</div> </div>

View File

@ -185,7 +185,7 @@
</div> </div>
</div> </div>
<div class="card-action right-align"> <div class="card-action right-align">
{{ submit_button(add_job_form.submit) }} {{ macros.submit_button(add_job_form.submit) }}
</div> </div>
</form> </form>
</div> </div>

View File

@ -76,7 +76,7 @@
</div> </div>
</div> </div>
<div class="card-action right-align"> <div class="card-action right-align">
{{ submit_button(add_job_form.submit) }} {{ macros.submit_button(add_job_form.submit) }}
</div> </div>
</form> </form>
</div> </div>