From 3da62ab97248f1730922b8b074092e96ed4cdf8c Mon Sep 17 00:00:00 2001 From: Aaron Gustafson Date: Wed, 22 Apr 2020 20:54:40 -0700 Subject: [PATCH 1/4] refactor descriptions --- src/_includes/macros/form.njk | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/src/_includes/macros/form.njk b/src/_includes/macros/form.njk index 08599715..6d4aa56d 100644 --- a/src/_includes/macros/form.njk +++ b/src/_includes/macros/form.njk @@ -23,7 +23,7 @@ > {% if data.description %}
- {{ data.description }} + {{ description( name, data.description ) }} {% endif %} {% endmacro %} @@ -41,7 +41,7 @@ {% if data.description %}
- {{ data.description }} + {{ description( name, data.description ) }} {% endif %} {% endmacro %} @@ -65,7 +65,7 @@ {% if data.description %}
- {{ data.description }} + {{ description( name, data.description ) }} {% endif %} {% endmacro %} @@ -82,7 +82,7 @@ {% if data.description %}aria-describedby="description-{{ name }}"{% endif %} > {% if data.description %} - {{ data.description }} + {{ description( name, data.description ) }} {% endif %} {% endmacro %} @@ -112,13 +112,13 @@ {% endif %} {% if option.note %}
- {{ option.note }} + {{ description( ( name + '-' + option.value ), option.note ) }} {% endif %} {% endfor %} {% if data.description %} - {{ data.description }} + {{ description( name, data.description ) }} {% endif %} {% endmacro %} @@ -149,17 +149,21 @@ {% endif %} {% if option.note %}
- {{ option.note }} + {{ description( ( name + '-' + option.value ), option.note ) }} {% endif %} {% endfor %} {% if data.description %} - {{ data.description }} + {{ description( name, data.description ) }} {% endif %} {% endmacro %} +{% macro description( id, html ) %} + {{ html | safe }} +{% endmacro %} + {% macro button( text ) %} {% endmacro %} From 7874a8fc1c6d2ec31b021cb1a2393f7e213f4312 Mon Sep 17 00:00:00 2001 From: Aaron Gustafson Date: Wed, 22 Apr 2020 20:55:58 -0700 Subject: [PATCH 2/4] refactor options --- src/_includes/macros/form.njk | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/src/_includes/macros/form.njk b/src/_includes/macros/form.njk index 6d4aa56d..f6ffc6fb 100644 --- a/src/_includes/macros/form.njk +++ b/src/_includes/macros/form.njk @@ -53,14 +53,14 @@ {% if data.multiple %}multiple{% endif %} {% if data.description %}aria-describedby="description-{{ name }}"{% endif %} > - {% for option in data.options_before %} - + {% for opt in data.options_before %} + {{ option( opt ) }} {% endfor %} - {% for option in options %} - + {% for opt in options %} + {{ option( opt ) }} {% endfor %} - {% for option in data.options_after %} - + {% for opt in data.options_after %} + {{ option( opt ) }} {% endfor %} {% if data.description %} @@ -69,6 +69,14 @@ {% endif %} {% endmacro %} +{% macro option( data ) %} + {% if data.value %} + + {% else %} + + {% endif %} +{% endmacro %} + {% macro textarea( name, data ) %}