This macro generates an h1, p (optional) and a list of error links
heading
summary
errors
Name | Description |
---|---|
heading | sets the h1 |
summary | sets an optional p |
errors | object of key value pairs for links |
If no errors are supplied then the macro response will be empty.
You have to pass these as an object of key value pairs
{
one: 'two',
three: 'four'
}
The above will generate two links the first link as an example will have a href of #one-form and text of two.
You will need to expose the views to the nunjucks config, an example is below.
const appViews = [path.join(__dirname, '/app/views/'),
path.join(__dirname, '/node_modules/govuk-elements-nunjucks/components/'),
path.join(__dirname, '/lib/')]
const nunjucksAppEnv = nunjucks.configure(appViews, {
autoescape: true,
express: app,
noCache: true,
watch: true
})
Include the nunjucks macro and render it like so:
{% from 'gov-error-summary/macro.njk' import govErrorSummary %}
{{ govErrorSummary('Heading', '', {test: 'test 1'}) }}