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

Update to GOV.UK Frontend v5.2.0 on management pages #2396

Merged
merged 3 commits into from
Feb 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
### Fixes

- [#2327: Use GOV.UK Frontend v5 on management pages and tests](https://github.com/alphagov/govuk-prototype-kit/pull/2327)
- [#2395: Update to GOV.UK Frontend v5.2.0 on management pages](https://github.com/alphagov/govuk-prototype-kit/pull/2395)

## 13.16.0

Expand Down
14 changes: 9 additions & 5 deletions lib/manage-prototype-handlers.js
Original file line number Diff line number Diff line change
Expand Up @@ -283,18 +283,22 @@ function locateTemplateConfig (req) {
}

function getTemplatesViewHandler (req, res) {
const model = {
pluginConfig: plugins.getAppConfig({ scripts: prototypeAppScripts }),
serviceName: 'Service name goes here'
}
const templateConfig = locateTemplateConfig(req)

// Nunjucks environment for template previews uses `getAppViews()` to
// add plugins including GOV.UK Frontend views via project package
const nunjucksAppEnv = nunjucksConfiguration.getNunjucksAppEnv(appViews)

// Use GOV.UK Frontend paths from Express.js locals
const { govukFrontend, govukFrontendInternal } = req.app.locals

if (templateConfig) {
res.send(nunjucksAppEnv.render(templateConfig.path, model))
res.send(nunjucksAppEnv.render(templateConfig.path, {
govukFrontend,
govukFrontendInternal,
Comment on lines +297 to +298
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For template previews we use a minimal Nunjucks context only

But to correctly build assetPath we need GOV.UK Frontend paths to close #2392

{%- set assetPath = assetPath | default('/plugin-assets/govuk-frontend' + govukFrontend.assetPath) -%}

{%- set assetPath = '/manage-prototype/dependencies/govuk-frontend' + govukFrontendInternal.assetPath -%}

pluginConfig: plugins.getAppConfig({ scripts: prototypeAppScripts }),
serviceName: 'Service name goes here'
}))
} else {
res.status(404).send('Template not found.')
}
Expand Down
14 changes: 7 additions & 7 deletions npm-shrinkwrap.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@
"express": "^4.18.2",
"express-session": "^1.17.3",
"fs-extra": "^11.1.1",
"govuk-frontend": "5.0.0",
"govuk-frontend": "5.2.0",
"inquirer": "^8.2.6",
"lodash": "^4.17.21",
"marked": "^4.3.0",
Expand Down
Loading