diff options
author | Samy Pessé <samypesse@gmail.com> | 2015-09-15 11:48:18 +0200 |
---|---|---|
committer | Samy Pessé <samypesse@gmail.com> | 2015-09-15 11:48:18 +0200 |
commit | 87e4ee1eeb9918cbf151407c66b3377014612d5d (patch) | |
tree | ce283acc1495272a66f55132130d00d36e53cc6b /lib | |
parent | 45833eea9ad5fb97ab5e5095e4e4b8e3481c7d2e (diff) | |
download | gitbook-87e4ee1eeb9918cbf151407c66b3377014612d5d.zip gitbook-87e4ee1eeb9918cbf151407c66b3377014612d5d.tar.gz gitbook-87e4ee1eeb9918cbf151407c66b3377014612d5d.tar.bz2 |
Handle absolute file correctly for conrefs
Add test for absolute file for conrefs
Diffstat (limited to 'lib')
-rw-r--r-- | lib/template.js | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/lib/template.js b/lib/template.js index b1bc632..65f24c5 100644 --- a/lib/template.js +++ b/lib/template.js @@ -31,7 +31,7 @@ var BookLoader = nunjucks.Loader.extend({ .then(function(filepath) { // Is local file if (!filepath) filepath = path.resolve(fileurl); - else that.book.log.debug.ln("resolve from git", fileurl, "to", filepath) + else that.book.log.debug.ln("resolve from git", fileurl, "to", filepath); // Read file from absolute path return fs.readFile(filepath) @@ -53,6 +53,12 @@ var BookLoader = nunjucks.Loader.extend({ // If origin is not in the book (include from a git content ref) return path.resolve(path.dirname(from), to); + }, + + // Handle all files as relative, so that nunjucks pass responsability to "resolve" + // Only git urls are considered as absolute + isRelative: function(filename) { + return !git.checkUrl(filename); } }); |