diff --git a/index.js b/index.js index 42856dc..0714b5d 100644 --- a/index.js +++ b/index.js @@ -12,6 +12,7 @@ const ENGINE = { module.exports = () => { const debug = require('debug')('web:templates:pug') + const path = require('path') const pug = require('pug') const requireDir = require('require-dir') @@ -53,11 +54,14 @@ module.exports = () => { EnginePug.prototype.initialise = function () { debug('Pug initialised') - if (this.config.engines && - this.config.engines.pug && - this.config.engines.pug.paths && this.config.engines.pug.paths.helpers + const engineConfig = this.config.get('engines') + + if (engineConfig && + engineConfig.pug && + engineConfig.pug.paths && engineConfig.pug.paths.helpers ) { - this.helperFunctions = requireDir(this.config.engines.pug.paths.helpers, { recurse: true, camelcase: true }) + const helperPath = path.join(process.cwd(), engineConfig.pug.paths.helpers) + this.helperFunctions = requireDir(helperPath, { recurse: true, camelcase: true }) } } diff --git a/test/pug.js b/test/pug.js index eef1887..74ad7a2 100644 --- a/test/pug.js +++ b/test/pug.js @@ -52,7 +52,7 @@ describe('Pug.js interface', function () { const Engine = factory() const instance = new Engine({ additionalTemplates: Object.keys(helpers.additionalTemplates).map(name => helpers.additionalTemplates[name]), - config: config.config, + config: config, pagesPath: path.join(helpers.paths.workspace, 'pages') }) @@ -69,7 +69,7 @@ describe('Pug.js interface', function () { const Engine = factory() const instance = new Engine({ additionalTemplates: Object.keys(helpers.additionalTemplates).map(name => helpers.additionalTemplates[name]), - config: config.config, + config: config, pagesPath: path.join(helpers.paths.workspace, 'pages') }) @@ -83,7 +83,7 @@ describe('Pug.js interface', function () { const Engine = factory() const instance = new Engine({ additionalTemplates: Object.keys(helpers.additionalTemplates).map(name => helpers.additionalTemplates[name]), - config: config.config, + config: config, pagesPath: path.join(helpers.paths.workspace, 'pages') }) @@ -129,7 +129,7 @@ describe('Pug.js interface', function () { const Engine = factory() const instance = new Engine({ additionalTemplates: Object.keys(helpers.additionalTemplates).map(name => helpers.additionalTemplates[name]), - config: config.config, + config: config, pagesPath: path.join(helpers.paths.workspace, 'pages') })