Skip to content

Commit 2e93f62

Browse files
Add attributes macro (#998)
* Add attributes macro copied from GOV.UK
1 parent 7118439 commit 2e93f62

File tree

33 files changed

+196
-43
lines changed

33 files changed

+196
-43
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
## Unreleased
44

55
- Fix Sass deprecation on `mix` function (passing a number without unit) ([PR 995](https://github.com/nhsuk/nhsuk-frontend/pull/995))
6+
- Add nhsukAttributes macro, copied from GOV.UK ([PR 998](https://github.com/nhsuk/nhsuk-frontend/pull/998))
67

78
## 8.3.0 - 24 July 2024
89

packages/components/action-link/template.njk

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
1+
{% from "../../macros/attributes.njk" import nhsukAttributes %}
2+
13
<div class="nhsuk-action-link">
24
<a class="nhsuk-action-link__link
35
{%- if params.classes %} {{ params.classes }}{% endif %}" href="
46
{%- if params.href %}{{ params.href }}{% else %}#{% endif %}"
57
{%- if params.openInNewWindow %} target="_blank"{% endif %}
6-
{%- for attribute, value in params.attributes %} {{attribute}}="{{ value }}"{% endfor %}>
8+
{{- nhsukAttributes(params.attributes) }}>
79
<svg class="nhsuk-icon nhsuk-icon__arrow-right-circle" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" aria-hidden="true" width="36" height="36">
810
<path d="M0 0h24v24H0z" fill="none"></path>
911
<path d="M12 2a10 10 0 0 0-9.95 9h11.64L9.74 7.05a1 1 0 0 1 1.41-1.41l5.66 5.65a1 1 0 0 1 0 1.42l-5.66 5.65a1 1 0 0 1-1.41 0 1 1 0 0 1 0-1.41L13.69 13H2.05A10 10 0 1 0 12 2z"></path>

packages/components/back-link/template.njk

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
{% from "../../macros/attributes.njk" import nhsukAttributes %}
2+
13
<div class="nhsuk-back-link{%- if params.classes %} {{ params.classes }}{% endif %}">
24
{%- if params.element == 'button' %}
35
{% set element='button' %}
@@ -6,7 +8,7 @@
68
{% endif %}
79
<{{element}} class="nhsuk-back-link__link"
810
{%- if element == 'a'%} href="{% if params.href %}{{ params.href }}{% else %}#{% endif %}"{% endif %}
9-
{%- for attribute, value in params.attributes %} {{attribute}}="{{value}}"{% endfor %}>
11+
{{- nhsukAttributes(params.attributes) }}>
1012
<svg class="nhsuk-icon nhsuk-icon__chevron-left" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" aria-hidden="true" height="24" width="24">
1113
<path d="M8.5 12c0-.3.1-.5.3-.7l5-5c.4-.4 1-.4 1.4 0s.4 1 0 1.4L10.9 12l4.3 4.3c.4.4.4 1 0 1.4s-1 .4-1.4 0l-5-5c-.2-.2-.3-.4-.3-.7z"></path>
1214
</svg>

packages/components/breadcrumb/template.njk

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
1+
{% from "../../macros/attributes.njk" import nhsukAttributes %}
2+
13
<nav class="nhsuk-breadcrumb{% if params.classes %} {{ params.classes }}{% endif %}" aria-label="Breadcrumb"
2-
{%- for attribute, value in params.attributes %} {{attribute}}="{{value}}"{% endfor %}>
4+
{{- nhsukAttributes(params.attributes) }}>
35
<div class="nhsuk-width-container">
46
<ol class="nhsuk-breadcrumb__list">
57
{%- for item in params.items %}
68
{%- if item.href %}
7-
<li class="nhsuk-breadcrumb__item"><a class="nhsuk-breadcrumb__link" href="{{ item.href }}"{% for attribute, value in item.attributes %} {{attribute}}="{{value}}"{% endfor %}>{{ item.text }}</a>{% if not loop.last %}{% endif %}</li>
9+
<li class="nhsuk-breadcrumb__item"><a class="nhsuk-breadcrumb__link" href="{{ item.href }}" {{- nhsukAttributes(item.attributes) }}>{{ item.text }}</a>{% if not loop.last %}{% endif %}</li>
810
{%- endif -%}
911
{% endfor %}
1012
{% if params.href %}
@@ -18,7 +20,7 @@
1820
{% endif %}
1921
</ol>
2022
<p class="nhsuk-breadcrumb__back">
21-
<a class="nhsuk-breadcrumb__backlink" href="{{ lastHref }}" {% for attribute, value in lastItem.attributes %}{{attribute}}="{{value}}"{% endfor %}>
23+
<a class="nhsuk-breadcrumb__backlink" href="{{ lastHref }}" {{- nhsukAttributes(lastItem.attributes) }}>
2224
<span class="nhsuk-u-visually-hidden">Back to &nbsp;</span>
2325
{{ lastText }}
2426
</a>

packages/components/button/template.njk

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
{% from "../../macros/attributes.njk" import nhsukAttributes %}
2+
13
{# Define type of element to use, if not explicitly set #}
24

35
{% if params.element %}
@@ -16,7 +18,7 @@
1618
{%- if params.disabled %} nhsuk-button--disabled{% endif %}"
1719
data-module="nhsuk-button"
1820
{% if params.preventDoubleClick %} data-prevent-double-click="true"{% endif %}
19-
{%- for attribute, value in params.attributes %} {{attribute}}="{{value}}"{% endfor %}
21+
{{- nhsukAttributes(params.attributes) }}
2022
{%- endset -%}
2123

2224
{# Define common attributes we can use for both button and input types #}

packages/components/card/template.njk

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
{% from "../../macros/attributes.njk" import nhsukAttributes %}
2+
13
{% set headingLevel = params.headingLevel if params.headingLevel else 2 %}
24

35
<div class="nhsuk-card
@@ -7,7 +9,7 @@
79
{%- if params.feature %} nhsuk-card--feature{% endif %}
810
{%- if params.topTask %} nhsuk-card--top-task{% endif %}
911
{%- if params.classes %} {{ params.classes }}{% endif %}"
10-
{%- for attribute, value in params.attributes %} {{attribute}}="{{value}}"{% endfor %}>
12+
{{- nhsukAttributes(params.attributes) }}>
1113
{%- if params.imgURL %}
1214
<img class="nhsuk-card__img" src="{{ params.imgURL }}" alt="{{ params.imgALT }}">
1315
{%- endif %}

packages/components/checkboxes/template.njk

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
{% from "../fieldset/macro.njk" import fieldset %}
33
{% from "../hint/macro.njk" import hint %}
44
{% from "../label/macro.njk" import label %}
5+
{% from "../../macros/attributes.njk" import nhsukAttributes %}
56

67
{#- If an id 'prefix' is not passed, fall back to using the name attribute
78
instead. We need this for error messages and hints as well -#}
@@ -42,7 +43,7 @@
4243
}) | indent(2) | trim }}
4344
{% endif %}
4445
<div class="nhsuk-checkboxes {%- if params.classes %} {{ params.classes }}{% endif %} {%- if isConditional %} nhsuk-checkboxes--conditional{% endif -%}"
45-
{%- for attribute, value in params.attributes %} {{ attribute }}="{{ value }}"{% endfor %}>
46+
{{- nhsukAttributes(params.attributes) }}>
4647
{% for item in params.items %}
4748
{% set id = item.id if item.id else idPrefix + "-" + loop.index %}
4849
{% set name = item.name if item.name else params.name %}
@@ -60,7 +61,7 @@
6061
{%- if item.exclusiveGroup %} data-checkbox-exclusive-group="{{ item.exclusiveGroup }}"{% endif -%}
6162
{%- if item.conditional %} aria-controls="{{ conditionalId }}" aria-expanded="{{"true" if item.checked else "false"}}"{% endif -%}
6263
{%- if hasHint %} aria-describedby="{{ itemHintId }}"{% endif -%}
63-
{%- for attribute, value in item.attributes %} {{ attribute }}="{{ value }}"{% endfor -%}>
64+
{{- nhsukAttributes(item.attributes) }}>
6465
{{ label({
6566
html: item.html,
6667
text: item.text,

packages/components/contents-list/template.njk

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
1+
{% from "../../macros/attributes.njk" import nhsukAttributes %}
2+
13
<nav class="nhsuk-contents-list
24
{%- if params.classes %} {{ params.classes }}{% endif %}"
3-
{%- for attribute, value in params.attributes %} {{attribute}}="{{value}}"{% endfor %} role="navigation" aria-label="Pages in this guide">
5+
{{- nhsukAttributes(params.attributes) }} role="navigation" aria-label="Pages in this guide">
46
<h2 class="nhsuk-u-visually-hidden">Contents</h2>
57
<ol class="nhsuk-contents-list__list">
68
{%- for item in params.items %}

packages/components/date-input/template.njk

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
{% from "../fieldset/macro.njk" import fieldset %}
33
{% from "../hint/macro.njk" import hint %}
44
{% from "../input/macro.njk" import input %}
5+
{% from "../../macros/attributes.njk" import nhsukAttributes %}
56

67
{#- a record of other elements that we need to associate with the input using
78
aria-describedby – for example hints or error messages -#}
@@ -52,7 +53,7 @@
5253
{% endif %}
5354
<div class="nhsuk-date-input
5455
{%- if params.classes %} {{ params.classes }}{% endif %}"
55-
{%- for attribute, value in params.attributes %} {{attribute}}="{{value}}"{% endfor %}
56+
{{- nhsukAttributes(params.attributes) }}
5657
{%- if params.id %} id="{{ params.id }}"{% endif %}>
5758
{%- for item in dateInputItems %}
5859
<div class="nhsuk-date-input__item">

packages/components/details/template.njk

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
1+
{% from "../../macros/attributes.njk" import nhsukAttributes %}
2+
13
<details {%- if params.id %} id="{{params.id}}"{% endif %} class="nhsuk-details
24
{%- if params.classes %} {{ params.classes }}{% endif %}"
3-
{%- for attribute, value in params.attributes %} {{attribute}}="{{value}}"{% endfor %} {{- " open" if params.open }}>
5+
{{- nhsukAttributes(params.attributes) }} {{- " open" if params.open }}>
46
<summary class="nhsuk-details__summary">
57
<span class="nhsuk-details__summary-text">
68
{{ params.text }}

packages/components/do-dont-list/template.njk

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
1+
{% from "../../macros/attributes.njk" import nhsukAttributes %}
2+
13
{% set headingLevel = params.headingLevel if params.headingLevel else 3 %}
24
<div class="nhsuk-do-dont-list
35
{%- if params.classes %} {{ params.classes }}{% endif %}"
4-
{%- for attribute, value in params.attributes %} {{attribute}}="{{value}}"{% endfor %}>
6+
{{- nhsukAttributes(params.attributes) }}>
57
<h{{ headingLevel }} class="nhsuk-do-dont-list__label">{{ params.title }}</h{{ headingLevel }}>
68
<ul class="nhsuk-list {% if params.type == 'tick' %}nhsuk-list--tick{% else %}nhsuk-list--cross{% endif %}" role="list">
79
{%- for data in params.items %}
Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
1+
{% from "../../macros/attributes.njk" import nhsukAttributes %}
2+
13
{% set visuallyHiddenText = params.visuallyHiddenText | default("Error") -%}
24

35
<span class="nhsuk-error-message
46
{%- if params.classes %} {{ params.classes }}{% endif %}"
57
{%- if params.id %} id="{{ params.id }}"{% endif %}
6-
{%- for attribute, value in params.attributes %} {{ attribute }}="{{ value }}"{% endfor %}>
8+
{{- nhsukAttributes(params.attributes) }}>
79
{% if visuallyHiddenText %}<span class="nhsuk-u-visually-hidden">{{ visuallyHiddenText }}:</span> {% endif -%}
810
{{ params.html | safe if params.html else params.text }}
911
</span>

packages/components/error-summary/template.njk

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
1+
{% from "../../macros/attributes.njk" import nhsukAttributes %}
2+
13
<div class="nhsuk-error-summary
24
{%- if params.classes %} {{ params.classes }}{% endif %}" aria-labelledby="error-summary-title" role="alert" tabindex="-1"
3-
{%- for attribute, value in params.attributes %} {{ attribute }}="{{ value }}"{% endfor %}>
5+
{{- nhsukAttributes(params.attributes) }}>
46
<h2 class="nhsuk-error-summary__title" id="error-summary-title">
57
{{ params.titleHtml | safe if params.titleHtml else params.titleText }}
68
</h2>
@@ -14,7 +16,7 @@
1416
{%- for item in params.errorList %}
1517
<li>
1618
{%- if item.href %}
17-
<a href="{{ item.href }}"{% for attribute, value in item.attributes %} {{attribute}}="{{value}}"{% endfor %}>{{ item.html | safe if item.html else item.text }}</a>
19+
<a href="{{ item.href }}"{{- nhsukAttributes(item.attributes) }}>{{ item.html | safe if item.html else item.text }}</a>
1820
{% else %}
1921
{{ item.html | safe if item.html else item.text }}
2022
{%- endif -%}

packages/components/fieldset/template.njk

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
1+
{% from "../../macros/attributes.njk" import nhsukAttributes %}
2+
13
<fieldset class="nhsuk-fieldset
24
{%- if params.classes %} {{ params.classes }}{% endif %}"
35
{%- if params.describedBy %} aria-describedby="{{ params.describedBy }}"{% endif %}
4-
{%- for attribute, value in params.attributes %} {{ attribute }}="{{ value }}"{% endfor %}>
6+
{{- nhsukAttributes(params.attributes) }}>
57
{%- if params.legend.html or params.legend.text %}
68
<legend class="nhsuk-fieldset__legend{%- if params.legend.classes %} {{ params.legend.classes }}{% endif %}">
79
{%- if params.legend.isPageHeading %}

packages/components/footer/template.njk

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
{% from "../../macros/attributes.njk" import nhsukAttributes %}
2+
13
{%- set copyrightText = params.copyright if params.copyright else '© NHS England' -%}
24

35
<footer role="contentinfo">
@@ -6,7 +8,7 @@
68
<h2 class="nhsuk-u-visually-hidden">Support links</h2>
79
<div class="nhsuk-footer
810
{%- if params.classes %} {{ params.classes }}{% endif %}"
9-
{%- for attribute, value in params.attributes %} {{ attribute }}="{{ value }}"{% endfor %}>
11+
{{- nhsukAttributes(params.attributes) }}>
1012
{% if not params.linksColumn2 %}
1113
<ul class="nhsuk-footer__list">
1214
{%- for item in params.links %}

packages/components/header/template.njk

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
{% from "../../macros/attributes.njk" import nhsukAttributes %}
2+
13
{# Define some defaults #}
24
{% set showNav = params.showNav if params.showNav else "false" %}
35
{% set showSearch = params.showSearch if params.showSearch else "false" %}
@@ -13,7 +15,7 @@
1315
{%- if params.transactional or params.transactionalService %} nhsuk-header__transactional{% endif %}
1416
{%- if params.organisation and params.organisation.name %} nhsuk-header--organisation{% endif %}
1517
{%- if params.classes %} {{ params.classes }}{% endif %}" role="banner"
16-
{%- for attribute, value in params.attributes %} {{ attribute }}="{{ value }}"{% endfor %}>
18+
{{- nhsukAttributes(params.attributes) }}>
1719

1820
<div class="nhsuk-header__container">
1921
<div class="nhsuk-header__logo
@@ -80,7 +82,7 @@
8082
<nav class="nhsuk-navigation" id="header-navigation" role="navigation" aria-label="Primary navigation">
8183
<ul class="nhsuk-header__navigation-list {%- if params.primaryLinks.length < 4 %} nhsuk-header__navigation-list--left-aligned{% endif %}">
8284
{%- for item in params.primaryLinks %}
83-
<li class="nhsuk-header__navigation-item {%- if item.classes %} {{ item.classes }}{% endif %}" {%- for attribute, value in item.attributes %} {{ attribute }}="{{ value }}"{% endfor %}>
85+
<li class="nhsuk-header__navigation-item {%- if item.classes %} {{ item.classes }}{% endif %}" {{- nhsukAttributes(item.attributes) }}>
8486
<a class="nhsuk-header__navigation-link" href="{{item.url}}">
8587
{{item.label}}
8688
</a>
@@ -138,7 +140,7 @@
138140
<nav class="nhsuk-navigation" id="header-navigation" role="navigation" aria-label="Primary navigation">
139141
<ul class="nhsuk-header__navigation-list {%- if params.primaryLinks.length < 4 %} nhsuk-header__navigation-list--left-aligned{% endif %}">
140142
{%- for item in params.primaryLinks %}
141-
<li class="nhsuk-header__navigation-item {%- if item.classes %} {{ item.classes }}{% endif %}" {%- for attribute, value in item.attributes %} {{ attribute }}="{{ value }}"{% endfor %}>
143+
<li class="nhsuk-header__navigation-item {%- if item.classes %} {{ item.classes }}{% endif %}" {{- nhsukAttributes(item.attributes) }}>
142144
<a class="nhsuk-header__navigation-link" href="{{item.url}}">
143145
{{item.label}}
144146
</a>
@@ -164,4 +166,4 @@
164166

165167
{% endif -%}
166168

167-
</header>
169+
</header>

packages/components/hero/template.njk

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
1+
{% from "../../macros/attributes.njk" import nhsukAttributes %}
2+
13
<section class="nhsuk-hero
24
{%- if params.imageURL and params.heading %} nhsuk-hero--image nhsuk-hero--image-description
35
{%- elif params.imageURL %} nhsuk-hero--image{% endif %}
46
{%- if params.classes %} {{ params.classes }}{% endif %}"
57
{%- if params.imageURL %} style="background-image: url('{{ params.imageURL }}');"{% endif %}
6-
{%- for attribute, value in params.attributes %} {{ attribute }}="{{ value }}"{% endfor %}>
8+
{{- nhsukAttributes(params.attributes) }}>
79
{% if params.imageURL %}<div class="nhsuk-hero__overlay">{% endif %}
810
{%- if params.heading %}
911
<div class="nhsuk-width-container{% if not params.imageURL %} nhsuk-hero--border{% endif %}">

packages/components/hint/template.njk

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
1+
{% from "../../macros/attributes.njk" import nhsukAttributes %}
2+
13
<div class="nhsuk-hint
24
{%- if params.classes %} {{ params.classes }}{% endif %}"
35
{%- if params.id %} id="{{ params.id }}"{% endif %}
4-
{%- for attribute, value in params.attributes %} {{attribute}}="{{value}}"{% endfor %}>
6+
{{- nhsukAttributes(params.attributes) }}>
57
{{ params.html | safe if params.html else params.text }}
68
</div>

packages/components/images/template.njk

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
1+
{% from "../../macros/attributes.njk" import nhsukAttributes %}
2+
13
<figure class="nhsuk-image
24
{%- if params.classes %} {{ params.classes }}{% endif %}"
3-
{%- for attribute, value in params.attributes %} {{attribute}}="{{value}}"{% endfor %}>
5+
{{- nhsukAttributes(params.attributes) }}>
46
<img class="nhsuk-image__img" src="{{ params.src }}" alt="{{ params.alt }}"
57
{%- if params.sizes and params.srcset %}
68
sizes="{{ params.sizes }}" srcset="{{ params.srcset }}"

packages/components/input/template.njk

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
{% from "../error-message/macro.njk" import errorMessage -%}
22
{% from "../hint/macro.njk" import hint %}
33
{% from "../label/macro.njk" import label %}
4+
{% from "../../macros/attributes.njk" import nhsukAttributes %}
45

56
{#- a record of other elements that we need to associate with the input using
67
aria-describedby – for example hints or error messages -#}
@@ -52,7 +53,7 @@
5253
{%- if params.autocomplete %} autocomplete="{{ params.autocomplete}}"{% endif %}
5354
{%- if params.pattern %} pattern="{{ params.pattern }}"{% endif %}
5455
{%- if params.inputmode %} inputmode="{{ params.inputmode }}"{% endif %}
55-
{%- for attribute, value in params.attributes %} {{ attribute }}="{{ value }}"{% endfor %}>
56+
{{- nhsukAttributes(params.attributes) }}>
5657
{%- if params.suffix %}
5758
<div class="nhsuk-input__suffix" aria-hidden="true">{{ params.suffix }}</div>
5859
{% endif %}

packages/components/inset-text/template.njk

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
1+
{% from "../../macros/attributes.njk" import nhsukAttributes %}
2+
13
<div class="nhsuk-inset-text
24
{%- if params.classes %} {{ params.classes }}{% endif %}"
3-
{%- for attribute, value in params.attributes %} {{attribute}}="{{value}}"{% endfor %}>
5+
{{- nhsukAttributes(params.attributes) }}>
46
<span class="nhsuk-u-visually-hidden">Information: </span>
57
{# params.HTML supported for backwards compatibility - see issue #950 #}
68
{{ (params.html or params.HTML) | safe }}

packages/components/label/template.njk

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
1+
{% from "../../macros/attributes.njk" import nhsukAttributes %}
2+
13
{% if params.html or params.text %}
24
{%- set labelHtml %}
35
<label class="nhsuk-label
46
{%- if params.classes %} {{ params.classes }}{% endif %}"
57
{%- if params.for %} for="{{ params.for }}"{% endif %}
6-
{%- for attribute, value in params.attributes %} {{attribute}}="{{value}}"{% endfor %}>
8+
{{- nhsukAttributes(params.attributes) }}>
79
{{ params.html | safe if params.html else params.text }}
810
</label>
911
{%- endset -%}

packages/components/pagination/template.njk

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
1+
{% from "../../macros/attributes.njk" import nhsukAttributes %}
2+
13
<nav class="nhsuk-pagination
24
{%- if params.classes %} {{ params.classes }}{% endif %}" role="navigation" aria-label="Pagination"
3-
{%- for attribute, value in params.attributes %} {{attribute}}="{{value}}"{% endfor %}>
5+
{{- nhsukAttributes(params.attributes) }}>
46
<ul class="nhsuk-list nhsuk-pagination__list">
57
{%- if params.previousUrl and params.previousPage %}
68
<li class="nhsuk-pagination-item--previous">

packages/components/radios/template.njk

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
{% from "../fieldset/macro.njk" import fieldset %}
33
{% from "../hint/macro.njk" import hint %}
44
{% from "../label/macro.njk" import label %}
5+
{% from "../../macros/attributes.njk" import nhsukAttributes %}
56

67
{#- If an id 'prefix' is not passed, fall back to using the name attribute
78
instead. We need this for error messages and hints as well -#}
@@ -43,7 +44,7 @@
4344
{% endif %}
4445
<div class="nhsuk-radios
4546
{%- if params.classes %} {{ params.classes }}{% endif %} {%- if isConditional %} nhsuk-radios--conditional{% endif -%}"
46-
{%- for attribute, value in params.attributes %} {{ attribute }}="{{ value }}"{% endfor %}>
47+
{{- nhsukAttributes(params.attributes) }}>
4748
{%- for item in params.items %}
4849
{%- set id = item.id if item.id else idPrefix + "-" + loop.index %}
4950
{% set conditionalId = "conditional-" + id %}
@@ -58,7 +59,7 @@
5859
{{-" disabled" if item.disabled }}
5960
{%- if item.conditional.html %} aria-controls="{{ conditionalId }}" aria-expanded="{{"true" if item.checked else "false"}}"{% endif -%}
6061
{%- if hasHint %} aria-describedby="{{ itemHintId }}"{% endif -%}
61-
{%- for attribute, value in item.attributes %} {{ attribute }}="{{ value }}"{% endfor -%}>
62+
{{- nhsukAttributes(item.attributes) }}>
6263
{{ label({
6364
html: item.html,
6465
text: item.text,

0 commit comments

Comments
 (0)