diff --git a/lib/manage-prototype-handlers.js b/lib/manage-prototype-handlers.js index bfd51f90fd..6ffc0e7f48 100644 --- a/lib/manage-prototype-handlers.js +++ b/lib/manage-prototype-handlers.js @@ -282,19 +282,23 @@ function locateTemplateConfig (req) { } } -function getTemplatesViewHandler (req, res) { - const model = { - pluginConfig: plugins.getAppConfig({ scripts: prototypeAppScripts }), - serviceName: 'Service name goes here' - } +function getTemplatesViewHandler(req, res) { 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, + pluginConfig: plugins.getAppConfig({ scripts: prototypeAppScripts }), + serviceName: 'Service name goes here' + })) } else { res.status(404).send('Template not found.') }