Summary list
<div class="asp-summary-list-container">
<dl class="asp-summary-list">
<dt class="asp-summary-list__key">
Question 1 (text)
</dt>
<dd class="asp-summary-list__value--fill">
Answer 1 (text) -- actions false
</dd>
</dl>
<dl class="asp-summary-list">
<dt class="asp-summary-list__key">
Question 2 <span>(html)</span>
</dt>
<dd class="asp-summary-list__value--fill">
Answer 2 <span>(html)</span>
</dd>
</dl>
<dl class="asp-summary-list">
<dt class="asp-summary-list__key">
Question 3
</dt>
<dd class="asp-summary-list__value">
Answer 3 with link as action
</dd>
<dd class="asp-summary-list__actions">
<a href="#">Link (text)</a>
</dd>
</dl>
<dl class="asp-summary-list">
<dt class="asp-summary-list__key">
Question 4
</dt>
<dd class="asp-summary-list__value">
Answer 4 with html status as action
</dd>
<dd class="asp-summary-list__actions">
Status
</dd>
</dl>
</div>
Nunjucks macro options
Use options to customise the appearance, content and behaviour of a component when using a macro, for example, changing the text.
Some options are required for the macro to work; these are marked as "Required" in the option description.
If you're using Nunjucks macros in production with "html" options, or ones ending with "html", you must sanitise the HTML to protect against cross-site scripting exploits.
Name | Type | Description |
---|---|---|
rows | object | rows. | Required. The rows within the summary list component. See
Options for rows
Name | Type | Description |
---|---|---|
key | array | key. | Required. The reference content (key) for each row item in the summary list component. See
value | array | value. | Required. The value for each row item in the summary list component. See
actions | array or false (boolean) | actions. | The action content for each row item in the summary list component. If false (boolean), the following parameters will be ignored. See
Options for key
Name | Type | Description |
---|---|---|
html | string | Required. HTML for each key. If 'html' is provided, the 'text' parameter will be ignored. |
text | string | Required. Text for each key. If 'html' is provided, the 'text' parameter will be ignored. |
Options for value
Name | Type | Description |
---|---|---|
html | string | Required. HTML for each value. If 'html' is provided, the 'text' parameter will be ignored. |
text | string | Required. Text for each value. If 'html' is provided, the 'text' parameter will be ignored. |
Options for actions
Name | Type | Description |
---|---|---|
href | string or false (boolean) | The URL for the action link. |
html | string | Required. HTML for each action item. This can be used to add visually hidden text or status components (avoid if actions.href is a string). If 'html' is provided, the 'text' parameter will be ignored. |
text | string | Required. Text for each action item. If 'html' is provided, the 'text' parameter will be ignored. |
{% from "summary-list/macro.njk" import aspSummaryList %}
{{ aspSummaryList({
rows: [
{
key: {
text: "Question 1 (text)"
},
value: {
text: "Answer 1 (text) -- actions false"
}
},
{
key: {
html: 'Question 2 <span>(html)</span>'
},
value: {
html: 'Answer 2 <span>(html)</span>'
}
},
{
key: {
text: "Question 3"
},
value: {
text: "Answer 3 with link as action"
},
actions: {
href: "#",
text: "Link (text)"
}
},
{
key: {
text: "Question 4"
},
value: {
text: "Answer 4 with html status as action"
},
actions: {
html: 'Status'
}
}
]
}) }}
Published 3 May 2024
Last updated 13 September 2024