@@ -6,10 +6,10 @@ import {
66 type ResponseToolkit ,
77 type RouteOptions
88} from '@hapi/hapi'
9- import vision from '@hapi/vision'
9+ // import vision from '@hapi/vision'
1010import { isEqual } from 'date-fns'
1111import Joi from 'joi'
12- import nunjucks , { type Environment } from 'nunjucks'
12+ // import nunjucks, { type Environment } from 'nunjucks'
1313
1414import { PREVIEW_PATH_PREFIX } from '~/src/server/constants.js'
1515import {
@@ -23,12 +23,12 @@ import {
2323 proceed ,
2424 redirectPath
2525} from '~/src/server/plugins/engine/helpers.js'
26- import {
27- PLUGIN_PATH ,
28- VIEW_PATH ,
29- context ,
30- prepareNunjucksEnvironment
31- } from '~/src/server/plugins/engine/index.js'
26+ // import {
27+ // PLUGIN_PATH,
28+ // VIEW_PATH,
29+ // context,
30+ // prepareNunjucksEnvironment
31+ // } from '~/src/server/plugins/engine/index.js'
3232import {
3333 FormModel ,
3434 SummaryViewModel
@@ -76,62 +76,62 @@ export const plugin = {
7676 name : '@defra/forms-engine-plugin' ,
7777 dependencies : [ '@hapi/crumb' , '@hapi/yar' , 'hapi-pino' ] ,
7878 multiple : true ,
79- async register ( server , options ) {
79+ register ( server , options ) {
8080 const {
8181 model,
8282 services = defaultServices ,
8383 controllers,
84- cacheName,
85- pluginPath = PLUGIN_PATH ,
86- filters
84+ cacheName
85+ // pluginPath = PLUGIN_PATH,
86+ // filters
8787 } = options
8888 const { formsService } = services
8989 const cacheService = new CacheService ( server , cacheName )
9090
9191 // Paths array to tell `vision` and `nunjucks` where template files are stored.
92- const path = [ `${ pluginPath } /${ VIEW_PATH } ` ]
93-
94- await server . register ( {
95- plugin : vision ,
96- options : {
97- engines : {
98- html : {
99- compile : (
100- path : string ,
101- compileOptions : { environment : Environment }
102- ) => {
103- const template = nunjucks . compile (
104- path ,
105- compileOptions . environment
106- )
107-
108- return ( context : object | undefined ) => {
109- return template . render ( context )
110- }
111- } ,
112- prepare : ( options : EngineConfigurationObject , next ) => {
113- // Nunjucks also needs an additional path configuration
114- // to use the templates and macros from `govuk-frontend`
115- const environment = nunjucks . configure ( [
116- ...path ,
117- 'node_modules/govuk-frontend/dist'
118- ] )
119-
120- // Applies custom filters and globals for nunjucks
121- // that are required by the `forms-engine-plugin`
122- prepareNunjucksEnvironment ( environment , filters )
123-
124- options . compileOptions . environment = environment
125-
126- next ( )
127- }
128- }
129- } ,
130- path,
131- // Provides global context used with all templates
132- context
133- }
134- } )
92+ // const path = [`${pluginPath}/${VIEW_PATH}`]
93+
94+ // await server.register({
95+ // plugin: vision,
96+ // options: {
97+ // engines: {
98+ // html: {
99+ // compile: (
100+ // path: string,
101+ // compileOptions: { environment: Environment }
102+ // ) => {
103+ // const template = nunjucks.compile(
104+ // path,
105+ // compileOptions.environment
106+ // )
107+
108+ // return (context: object | undefined) => {
109+ // return template.render(context)
110+ // }
111+ // },
112+ // prepare: (options: EngineConfigurationObject, next) => {
113+ // // Nunjucks also needs an additional path configuration
114+ // // to use the templates and macros from `govuk-frontend`
115+ // const environment = nunjucks.configure([
116+ // ...path,
117+ // 'node_modules/govuk-frontend/dist'
118+ // ])
119+
120+ // // Applies custom filters and globals for nunjucks
121+ // // that are required by the `forms-engine-plugin`
122+ // prepareNunjucksEnvironment(environment, filters)
123+
124+ // options.compileOptions.environment = environment
125+
126+ // next()
127+ // }
128+ // }
129+ // },
130+ // path,
131+ // // Provides global context used with all templates
132+ // context
133+ // }
134+ // })
135135
136136 server . expose ( 'cacheService' , cacheService )
137137
0 commit comments