summaryrefslogtreecommitdiffstats
path: root/lib/templating/conrefsLoader.js
diff options
context:
space:
mode:
Diffstat (limited to 'lib/templating/conrefsLoader.js')
-rw-r--r--lib/templating/conrefsLoader.js17
1 files changed, 15 insertions, 2 deletions
diff --git a/lib/templating/conrefsLoader.js b/lib/templating/conrefsLoader.js
index c3e5048..cdf0c30 100644
--- a/lib/templating/conrefsLoader.js
+++ b/lib/templating/conrefsLoader.js
@@ -12,12 +12,18 @@ var PathUtils = require('../utils/path');
- 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,
- init: function(rootFolder, logger) {
+ init: function(rootFolder, transformFn, logger) {
this.rootFolder = rootFolder;
+ this.transformFn = transformFn;
this.logger = logger;
this.git = new Git();
},
@@ -34,9 +40,16 @@ var ConrefsLoader = nunjucks.Loader.extend({
if (that.logger) that.logger.debug.ln('resolve from git', sourceURL, 'to', filepath);
}
- // Read file from absolute path
+ // Read file from absolute path
return fs.readFile(filepath)
.then(function(source) {
+ if (that.transformFn) {
+ return that.transformFn(filepath, source);
+ }
+
+ return source;
+ })
+ .then(function(source) {
return {
src: source.toString('utf8'),
path: filepath