diff options
author | Samy Pessé <samypesse@gmail.com> | 2016-05-02 09:38:24 +0200 |
---|---|---|
committer | Samy Pessé <samypesse@gmail.com> | 2016-05-02 09:38:24 +0200 |
commit | eb4631156153c6e656e41761a6330aa0e2beac28 (patch) | |
tree | 5f4a26cd37f8b3c2f08ad71df4b8bf5f8b3f6e5c /lib | |
parent | 63839bb0a7dd429b50b99109511737efed257e36 (diff) | |
download | gitbook-eb4631156153c6e656e41761a6330aa0e2beac28.zip gitbook-eb4631156153c6e656e41761a6330aa0e2beac28.tar.gz gitbook-eb4631156153c6e656e41761a6330aa0e2beac28.tar.bz2 |
getArticleByPath is now a global function for template instead of a filter
Diffstat (limited to 'lib')
-rw-r--r-- | lib/output/website/createTemplateEngine.js | 24 |
1 files changed, 15 insertions, 9 deletions
diff --git a/lib/output/website/createTemplateEngine.js b/lib/output/website/createTemplateEngine.js index 334ec13..daa591a 100644 --- a/lib/output/website/createTemplateEngine.js +++ b/lib/output/website/createTemplateEngine.js @@ -56,6 +56,21 @@ function createTemplateEngine(output, currentFile) { context: context, + globals: { + /** + Return an article by its path + + @param {String} articlePath + @return {Object|undefined} + */ + getArticleByPath: function(articlePath) { + var article = summary.getByPath(articlePath); + if (!article) return undefined; + + return JSONUtils.encodeSummaryArticle(article); + } + }, + filters: defaultFilters.merge({ /** Translate a sentence @@ -97,15 +112,6 @@ function createTemplateEngine(output, currentFile) { contentURL: function(filePath) { return fileToURL(output, filePath); - }, - - /** - Return an article by its path - */ - getArticleByPath: function(s) { - var article = summary.getByPath(s); - if (!article) return undefined; - return JSONUtils.encodeSummaryArticle(article); } }), |