Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Month (3) to word (March) Nunjucks filter #227

Open
chrimesdev opened this issue Feb 10, 2022 · 3 comments
Open

Month (3) to word (March) Nunjucks filter #227

chrimesdev opened this issue Feb 10, 2022 · 3 comments
Labels
JavaScript Pull requests that update Javascript code Nunjucks Pull requests that involve nunjucks functionality

Comments

@chrimesdev
Copy link
Member

chrimesdev commented Feb 10, 2022

Description

For the formatting of dates on the check your answers page in a prototype, I came across this this useful Nunjucks filter to change a number, like 1 "12" or 04, to a month in words: https://github.com/nhsuk/permission-to-contact-prototype/blob/master/app/filters.js#L12

I think this would be useful adding to main prototype kit?

@henocookie
Copy link
Contributor

This would help prototypes (and therefore services) meet the Dates guidance:

As far as possible, spell out months in full. Screen readers read out shortened months (Jan, Feb and so on) in inconsistent and sometimes confusing ways.

Good idea @chrimesdev 👏🏻

@GrilloPress
Copy link
Contributor

GrilloPress commented Feb 10, 2022

That code looks like something I wrote up for the app prototype ages ago. So I am sure there's a smarter way of writing it. The reason we wrote it was we were redesigning the appointment booking service.

We constantly needed to convert what was inputted into dates and reflected back to the user. So we needed the filter. It saved a load of code in each template file.

https://github.com/GrilloPress/contact-preference/blob/master/app/filters.js#L165

@frankieroberto
Copy link
Contributor

This filter: govukDate does something similar (but with a whole date rather than just the month number) - and can be added to NHS prototypes like this: https://github.com/NHSDigital/record-a-vaccination-prototype/blob/main/app/filters.js#L2-L11

It might still be worth considering importing this (and renaming to nhsDate?) and making it available as a core filter though, given dates are such a common field type to prototype?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
JavaScript Pull requests that update Javascript code Nunjucks Pull requests that involve nunjucks functionality
Development

No branches or pull requests

5 participants