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.js9
1 files changed, 8 insertions, 1 deletions
diff --git a/lib/templating/conrefsLoader.js b/lib/templating/conrefsLoader.js
index 52d2a95..475aa92 100644
--- a/lib/templating/conrefsLoader.js
+++ b/lib/templating/conrefsLoader.js
@@ -62,7 +62,14 @@ var ConrefsLoader = nunjucks.Loader.extend({
resolve: function(from, to) {
// If origin is in the book, we enforce result file to be in the book
if (PathUtils.isInRoot(this.rootFolder, from)) {
- var href = LocationUtils.toAbsolute(to, path.dirname(from), this.rootFolder);
+
+ // Path of current template in the rootFolder (not absolute to fs)
+ var fromRelative = path.relative(this.rootFolder, from);
+
+ // Resolve "to" to a filepath relative to rootFolder
+ var href = LocationUtils.toAbsolute(to, path.dirname(fromRelative), '');
+
+ // Return absolute path
return PathUtils.resolveInRoot(this.rootFolder, href);
}