From c9665369509a508af113f3ec3b1c191581ce740d Mon Sep 17 00:00:00 2001 From: Alice Gaudon Date: Tue, 3 Nov 2020 17:46:04 +0100 Subject: [PATCH] NunjucksComponent: fix view loaders using cache when in dev env --- src/components/NunjucksComponent.ts | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/components/NunjucksComponent.ts b/src/components/NunjucksComponent.ts index df62556..581d496 100644 --- a/src/components/NunjucksComponent.ts +++ b/src/components/NunjucksComponent.ts @@ -32,15 +32,16 @@ export default class NunjucksComponent extends ApplicationComponent { log.warn('Couldn\'t determine coreVersion.', e); } - this.environment = new nunjucks.Environment([ - ...this.viewsPath.map(path => new nunjucks.FileSystemLoader(path)), - new nunjucks.FileSystemLoader(path.join(__dirname, '../../../views')), - new nunjucks.FileSystemLoader(path.join(__dirname, '../views')), - ], { + const opts = { autoescape: true, noCache: !config.get('view.cache'), throwOnUndefined: true, - }) + }; + this.environment = new nunjucks.Environment([ + ...this.viewsPath.map(path => new nunjucks.FileSystemLoader(path, opts)), + new nunjucks.FileSystemLoader(path.join(__dirname, '../../../views'), opts), + new nunjucks.FileSystemLoader(path.join(__dirname, '../views'), opts), + ], opts) .addGlobal('route', ( route: string, params: RouteParams = [],