NunjucksComponent: fix view loaders using cache when in dev env

This commit is contained in:
Alice Gaudon 2020-11-03 17:46:04 +01:00
parent 7a4c157074
commit c966536950

View File

@ -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 = [],