{{ $bookSection := default "docs" .Site.Params.BookSection }} {{ if eq $bookSection "*" }} {{ $bookSection = "/" }}{{/* Backward compatibility */}} {{ end }} {{ with .Site.GetPage $bookSection }} {{ template "book-section-children" (dict "Section" . "CurrentPage" $) }} {{ end }} {{ define "book-section-children" }}{{/* (dict "Section" .Section "CurrentPage" .CurrentPage) */}} {{ $self := eq .CurrentPage .Section }} {{ $ancestor := strings.HasPrefix .CurrentPage.RelPermalink .Section.RelPermalink }} {{ $collapsed := .Section.Params.bookCollapseSection }} {{ if or $self $ancestor (not $collapsed) }}