Skip to content

Attributes macro not omitting None or lowering booleans #106

@colinrotherham

Description

@colinrotherham

Describe the bug
The macro govukAttributes() does not handle Python specific None, True and False values

To Reproduce
Notice how None appears in the output and booleans are not lowercased:

<div {{- govukAttributes({
  "a": undefined,
  "b": null,
  "c": None,
  "d": "",
  "e": 0,
  "f": False
}) }}></div>
- <div a="" b="" c="" d="" e="0" f="false"></div>
+ <div a="" b="" c="None" d="" e="0" f="False"></div>

Expected behavior

  • None values should be output "" (same as null, undefined)
  • True and False should be lowercased

Additional context
See our NHS fixes if helpful in NHSDigital/nhsuk-frontend-jinja@2a1938e

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions