diff options
author | Samy Pessé <samypesse@gmail.com> | 2016-04-20 10:03:04 +0200 |
---|---|---|
committer | Samy Pessé <samypesse@gmail.com> | 2016-04-20 10:03:04 +0200 |
commit | 8f40d4affa396318d3632c87aeabe56372b83e25 (patch) | |
tree | 0797c7b072ebb272b36837237aaed283f8af299a | |
parent | 560f3fcccb82ce4a781c311107212a0463ec8d65 (diff) | |
download | gitbook-8f40d4affa396318d3632c87aeabe56372b83e25.zip gitbook-8f40d4affa396318d3632c87aeabe56372b83e25.tar.gz gitbook-8f40d4affa396318d3632c87aeabe56372b83e25.tar.bz2 |
Fix reliability of template.self in macro import
-rw-r--r-- | lib/output/website/themeLoader.js | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/lib/output/website/themeLoader.js b/lib/output/website/themeLoader.js index bcfea5a..774a39e 100644 --- a/lib/output/website/themeLoader.js +++ b/lib/output/website/themeLoader.js @@ -35,10 +35,14 @@ var ThemeLoader = nunjucks.Loader.extend({ return null; } + var src = fs.readFileSync(fullpath, 'utf-8'); + + src = '{% do %}var template = template || {}; template.stack = template.stack || []; template.stack.push(template.self); template.self = ' + JSON.stringify(templateName) + '{% enddo %}\n' + + src + + '\n{% do %}template.self = template.stack.pop();{% enddo %}'; + return { - src: '{% do %}template = template || {}; template.stack = template.stack || []; template.stack.push(template.self); template.self = ' + JSON.stringify(templateName) + '{% enddo %}\n' + - fs.readFileSync(fullpath, 'utf-8') + - '\n{% do %}template.self = template.stack.pop();{% enddo %}', + src: src, path: fullpath, noCache: true }; |