Skip to content

Commit

Permalink
Indent HTML for Checkboxes
Browse files Browse the repository at this point in the history
  • Loading branch information
colinrotherham committed Feb 1, 2024
1 parent d4ac1cb commit 95eb0e6
Showing 1 changed file with 10 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,20 +25,20 @@
{% set conditionalId = "conditional-" + itemId %}
{%- if item.divider %}
<div class="govuk-checkboxes__divider">{{ item.divider }}</div>
{%- else %}
{% else %}
{% set isChecked = item.checked | default((item.value in params.values and item.checked != false) if params.values else false, true) %}
{% set hasHint = true if item.hint.text or item.hint.html %}
{% set itemHintId = itemId + "-item-hint" if hasHint else "" %}
{% set itemDescribedBy = describedBy if not hasFieldset else "" %}
{% set itemDescribedBy = (itemDescribedBy + " " + itemHintId) | trim %}
<div class="govuk-checkboxes__item">
<input class="govuk-checkboxes__input" id="{{ itemId }}" name="{{ itemName }}" type="checkbox" value="{{ item.value }}"
{{-" checked" if isChecked }}
{{-" disabled" if item.disabled }}
{%- if item.conditional.html %} data-aria-controls="{{ conditionalId }}"{% endif -%}
{%- if item.behaviour %} data-behaviour="{{ item.behaviour }}"{% endif -%}
{%- if itemDescribedBy %} aria-describedby="{{ itemDescribedBy }}"{% endif -%}
{%- for attribute, value in item.attributes %} {{ attribute }}="{{ value }}"{% endfor %}>
{{-" checked" if isChecked }}
{{-" disabled" if item.disabled }}
{%- if item.conditional.html %} data-aria-controls="{{ conditionalId }}"{% endif -%}
{%- if item.behaviour %} data-behaviour="{{ item.behaviour }}"{% endif -%}
{%- if itemDescribedBy %} aria-describedby="{{ itemDescribedBy }}"{% endif -%}
{%- for attribute, value in item.attributes %} {{ attribute }}="{{ value }}"{% endfor %}>
{{ govukLabel({
html: item.html,
text: item.text,
Expand All @@ -57,9 +57,9 @@
{% endif %}
</div>
{% if item.conditional.html %}
<div class="govuk-checkboxes__conditional {%- if not isChecked %} govuk-checkboxes__conditional--hidden{% endif %}" id="{{ conditionalId }}">
{{ item.conditional.html | safe }}
</div>
<div class="govuk-checkboxes__conditional {%- if not isChecked %} govuk-checkboxes__conditional--hidden{% endif %}" id="{{ conditionalId }}">
{{ item.conditional.html | safe | trim | indent(6) }}
</div>
{% endif %}
{% endif %}
{% endmacro -%}
Expand Down

0 comments on commit 95eb0e6

Please sign in to comment.