From c9ca7d6196ac8b353bda6a4446b1eaa54ad10dc1 Mon Sep 17 00:00:00 2001 From: Chris Gomez Date: Wed, 13 Jul 2016 09:35:50 -0400 Subject: [PATCH] Only render children in the last parent when hideChildrenInMenu is true (#252) --- lib/generators/html/build/make_default_helpers.js | 13 ++++++++++++- site/default/templates/menu.mustache | 4 +++- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/lib/generators/html/build/make_default_helpers.js b/lib/generators/html/build/make_default_helpers.js index cb10b75c9..5c669d3aa 100644 --- a/lib/generators/html/build/make_default_helpers.js +++ b/lib/generators/html/build/make_default_helpers.js @@ -679,7 +679,18 @@ module.exports = function(docMap, config, getCurrent, Handlebars){ } return ""; }, - + /** + * @function documentjs.generators.html.defaultHelpers.ifIsLastItem + * + * Renders the truthy section if the current context is the last item + * in the list. + * + * @param {Array} list + * @param {*} item + */ + ifIsLastItem: function(list, item, options){ + return list[list.length - 1] === item ? options.fn(this) : ''; + }, // makeApiSection: function(options){ var depth = (this.api && this.api !== this.name ? 1 : 0); diff --git a/site/default/templates/menu.mustache b/site/default/templates/menu.mustache index 8c222b3ed..db54eb6f2 100644 --- a/site/default/templates/menu.mustache +++ b/site/default/templates/menu.mustache @@ -6,7 +6,9 @@ {{makeTitle}} {{#if ../active.hideChildrenInMenu}} - {{> active-menu.mustache}} + {{#ifIsLastItem ../../parents .}} + {{> active-menu.mustache}} + {{/ifIsLastItem}} {{/if}} {{/each}}