diff options
Diffstat (limited to 'lib/templating/conrefsLoader.js')
-rw-r--r-- | lib/templating/conrefsLoader.js | 23 |
1 files changed, 12 insertions, 11 deletions
diff --git a/lib/templating/conrefsLoader.js b/lib/templating/conrefsLoader.js index 475aa92..b3cdb3f 100644 --- a/lib/templating/conrefsLoader.js +++ b/lib/templating/conrefsLoader.js @@ -8,16 +8,15 @@ var PathUtils = require('../utils/path'); /** - Template loader resolving both: - - relative url ("./test.md") - - absolute url ("/test.md") - - git url ("") - - - @param {String} rootFolder - @param {Function(filePath, source)} transformFn (optional) - @param {Logger} logger (optional) -*/ + * Template loader resolving both: + * - relative url ("./test.md") + * - absolute url ("/test.md") + * - git url ("") + * + * @param {String} rootFolder + * @param {Function(filePath, source)} transformFn (optional) + * @param {Logger} logger (optional) + */ var ConrefsLoader = nunjucks.Loader.extend({ async: true, @@ -43,6 +42,8 @@ var ConrefsLoader = nunjucks.Loader.extend({ // Read file from absolute path return fs.readFile(filepath) .then(function(source) { + source = source.toString('utf8'); + if (that.transformFn) { return that.transformFn(filepath, source); } @@ -51,7 +52,7 @@ var ConrefsLoader = nunjucks.Loader.extend({ }) .then(function(source) { return { - src: source.toString('utf8'), + src: source, path: filepath }; }); |