diff --git a/app/templates/admin/edit_user.html.j2 b/app/templates/admin/edit_user.html.j2 index 69f4cfca..dd4e640b 100644 --- a/app/templates/admin/edit_user.html.j2 +++ b/app/templates/admin/edit_user.html.j2 @@ -49,7 +49,7 @@
- {{ submit_button(edit_user_form.submit) }} + {{ macros.submit_button(edit_user_form.submit) }}
diff --git a/app/templates/auth/login.html.j2 b/app/templates/auth/login.html.j2 index ecd4df5c..d4ea5810 100644 --- a/app/templates/auth/login.html.j2 +++ b/app/templates/auth/login.html.j2 @@ -59,7 +59,7 @@
- {{ submit_button(login_form.submit) }} + {{ macros.submit_button(login_form.submit) }}
diff --git a/app/templates/auth/register.html.j2 b/app/templates/auth/register.html.j2 index 6b909297..a6fb20b6 100644 --- a/app/templates/auth/register.html.j2 +++ b/app/templates/auth/register.html.j2 @@ -57,7 +57,7 @@
- {{ submit_button(registration_form.submit) }} + {{ macros.submit_button(registration_form.submit) }}
diff --git a/app/templates/auth/reset_password.html.j2 b/app/templates/auth/reset_password.html.j2 index 178fa67a..6b947b69 100644 --- a/app/templates/auth/reset_password.html.j2 +++ b/app/templates/auth/reset_password.html.j2 @@ -27,7 +27,7 @@
- {{ submit_button(reset_password_form.submit) }} + {{ macros.submit_button(reset_password_form.submit) }}
diff --git a/app/templates/auth/reset_password_request.html.j2 b/app/templates/auth/reset_password_request.html.j2 index fa294d94..ee0203f1 100644 --- a/app/templates/auth/reset_password_request.html.j2 +++ b/app/templates/auth/reset_password_request.html.j2 @@ -20,7 +20,7 @@
- {{ submit_button(reset_password_request_form.submit) }} + {{ macros.submit_button(reset_password_request_form.submit) }}
diff --git a/app/templates/corpora/add_corpus.html.j2 b/app/templates/corpora/add_corpus.html.j2 index debfd1cf..413f3e6a 100644 --- a/app/templates/corpora/add_corpus.html.j2 +++ b/app/templates/corpora/add_corpus.html.j2 @@ -41,7 +41,7 @@
- {{ submit_button(add_corpus_form.submit) }} + {{ macros.submit_button(add_corpus_form.submit) }}
diff --git a/app/templates/corpora/add_corpus_file.html.j2 b/app/templates/corpora/add_corpus_file.html.j2 index acaad17f..479b4b62 100644 --- a/app/templates/corpora/add_corpus_file.html.j2 +++ b/app/templates/corpora/add_corpus_file.html.j2 @@ -1,18 +1,5 @@ {% extends "nopaque.html.j2" %} -{% macro render_field(field) %} -
- {{ field.name[0:1]|upper }} - {{ field.label }} - {{ field(data_length='255')|safe }} -
- {% if field.errors %} - {% for error in field.errors %} - {{ error }} - {% endfor %} - {% endif %} -{% endmacro %} - {% block page_content %}

{{ corpus.title }}

@@ -74,7 +61,7 @@
- {{ submit_button(add_corpus_file_form.submit) }} + {{ macros.submit_button(add_corpus_file_form.submit) }}

@@ -91,7 +78,7 @@ or field.name == "csrf_token" or field.name == "title" or field.name == "publishing_year") %} - {{ render_field(field)}} + {{ macros.render_field(field)}} {% endfor %} diff --git a/app/templates/corpora/edit_corpus_file.html.j2 b/app/templates/corpora/edit_corpus_file.html.j2 index 81f6726a..7a07855a 100644 --- a/app/templates/corpora/edit_corpus_file.html.j2 +++ b/app/templates/corpora/edit_corpus_file.html.j2 @@ -1,18 +1,5 @@ {% extends "nopaque.html.j2" %} -{% macro render_field_with_value(field, corpus_file) %} -
- {{ field.name[0:1]|upper }} - {{ field.label }} - {{ field(value=corpus_file[field.name], data_length='255')| safe }} -
- {% if field.errors %} - {% for error in field.errors %} - {{ error }} - {% endfor %} - {% endif %} -{% endmacro %} - {% block page_content %}

...

@@ -59,7 +46,7 @@
- {{ submit_button(edit_corpus_file_form.submit) }} + {{ macros.submit_button(edit_corpus_file_form.submit) }}

@@ -76,7 +63,7 @@ or field.name == "csrf_token" or field.name == "title" or field.name == "publishing_year") %} - {{ render_field_with_value(field, corpus_file)}} + {{ macros.render_field_with_value(field, corpus_file)}} {% endfor %} diff --git a/app/templates/macros.jinja b/app/templates/macros.jinja new file mode 100644 index 00000000..0e8e4ab4 --- /dev/null +++ b/app/templates/macros.jinja @@ -0,0 +1,31 @@ +{% macro render_field(field) %} +
+ {{ field.name[0:1]|upper }} + {{ field.label }} + {{ field(data_length='255')|safe }} +
+ {% if field.errors %} + {% for error in field.errors %} + {{ error }} + {% endfor %} + {% endif %} +{% endmacro %} + + +{% macro render_field_with_value(field, corpus_file) %} +
+ {{ field.name[0:1]|upper }} + {{ field.label }} + {{ field(value=corpus_file[field.name], data_length='255')| safe }} +
+ {% if field.errors %} + {% for error in field.errors %} + {{ error }} + {% endfor %} + {% endif %} +{% endmacro %} + + +{% macro submit_button(input) %} + +{% endmacro %} diff --git a/app/templates/main/index.html.j2 b/app/templates/main/index.html.j2 index 40c698fe..5bae3a83 100644 --- a/app/templates/main/index.html.j2 +++ b/app/templates/main/index.html.j2 @@ -123,7 +123,7 @@
- {{ submit_button(login_form.submit) }} + {{ macros.submit_button(login_form.submit) }}
diff --git a/app/templates/nopaque.html.j2 b/app/templates/nopaque.html.j2 index b5a10009..6eceaea4 100644 --- a/app/templates/nopaque.html.j2 +++ b/app/templates/nopaque.html.j2 @@ -1,6 +1,4 @@ -{% macro submit_button(input) %} - -{% endmacro %} +{% import "macros.jinja" as macros %} diff --git a/app/templates/profile/settings.html.j2 b/app/templates/profile/settings.html.j2 index 4b7b72fd..a2994afd 100644 --- a/app/templates/profile/settings.html.j2 +++ b/app/templates/profile/settings.html.j2 @@ -31,7 +31,7 @@
- {{ submit_button(edit_general_settings_form.save_settings) }} + {{ macros.submit_button(edit_general_settings_form.save_settings) }}
@@ -76,7 +76,7 @@
- {{ submit_button(edit_password_form.save_password) }} + {{ macros.submit_button(edit_password_form.save_password) }}
@@ -105,7 +105,7 @@
- {{ submit_button(edit_email_form.save_email) }} + {{ macros.submit_button(edit_email_form.save_email) }}
diff --git a/app/templates/services/nlp.html.j2 b/app/templates/services/nlp.html.j2 index 48e8a394..a7463b42 100644 --- a/app/templates/services/nlp.html.j2 +++ b/app/templates/services/nlp.html.j2 @@ -110,7 +110,7 @@
- {{ submit_button(add_job_form.submit) }} + {{ macros.submit_button(add_job_form.submit) }}
diff --git a/app/templates/services/ocr.html.j2 b/app/templates/services/ocr.html.j2 index e635380f..a968b1e2 100644 --- a/app/templates/services/ocr.html.j2 +++ b/app/templates/services/ocr.html.j2 @@ -185,7 +185,7 @@
- {{ submit_button(add_job_form.submit) }} + {{ macros.submit_button(add_job_form.submit) }}
diff --git a/app/templates/services/setup_files.html.j2 b/app/templates/services/setup_files.html.j2 index f3b7b2a9..8611a0e2 100644 --- a/app/templates/services/setup_files.html.j2 +++ b/app/templates/services/setup_files.html.j2 @@ -76,7 +76,7 @@
- {{ submit_button(add_job_form.submit) }} + {{ macros.submit_button(add_job_form.submit) }}