From eb4631156153c6e656e41761a6330aa0e2beac28 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Samy=20Pess=C3=A9?= Date: Mon, 2 May 2016 09:38:24 +0200 Subject: [PATCH] getArticleByPath is now a global function for template instead of a filter --- lib/output/website/createTemplateEngine.js | 24 ++++++++++++++-------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/lib/output/website/createTemplateEngine.js b/lib/output/website/createTemplateEngine.js index 334ec13ea..daa591a61 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); } }),