From b07450a27ae47dfa4ba0ef5fca4f63da2cfaa084 Mon Sep 17 00:00:00 2001 From: CDaxi Date: Mon, 10 Jun 2019 23:59:45 +0200 Subject: [PATCH] Avoid double registration of partials Same behaviour as for views: first path with found partial name will be used. If a partial with the same name is already registered, it will be ignored. Manual registration is still possible and will overwrite the partial. --- index.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/index.js b/index.js index 09e7f16..db162db 100644 --- a/index.js +++ b/index.js @@ -378,8 +378,11 @@ Hbs.prototype.registerPartials = function () { // Generate list of files and template names resultList.forEach((result, i) => { result.forEach((file) => { - files.push(path.join(self.partialsPath[i], file)); - names.push(file.slice(0, -1 * self.extname.length)); + let name = file.slice(0, -1 * self.extname.length); + if (names.indexOf(name) === -1) { + files.push(path.join(self.partialsPath[i], file)); + names.push(name); + } }); });