The govukAttributes macro, when provided a map of key-value pairs, will fail to output values that have previously passed through the Nunjucks safe filter.
This appears to be because the output of the safe filter is (if not null) actually an object, which the govukAttributes macro is interpreting to be one of our first-party attribute configuration objects.
Steps to reproduce the issue
Use this code in a project using GOV.UK Frontend's Nunjucks macros. The use of Back Link component here is illustrative, this issue is present in all components that use govukAttributes.
Raised and investigated via support.
Description of the issue
The
govukAttributes
macro, when provided a map of key-value pairs, will fail to output values that have previously passed through the Nunjuckssafe
filter.This appears to be because the output of the
safe
filter is (if notnull
) actually an object, which thegovukAttributes
macro is interpreting to be one of our first-party attribute configuration objects.Steps to reproduce the issue
Use this code in a project using GOV.UK Frontend's Nunjucks macros. The use of Back Link component here is illustrative, this issue is present in all components that use
govukAttributes
.Each of the
safe
filtered values as they're exposed by thedump
filter. Thesafe
filter appears to convert anything passed to it into a string.Actual vs expected behaviour
(HTML output has been reformatted for easier reading.)
Actual output
Expected output
Environment (where applicable)