{{/* Get the last leaf section for a given section, respecting the ordering of each intermediate section. If there is no sub-section to the given section, returns the section itself. Expects a section -- NOT A REGULAR PAGE -- to be given as argument. Returns a Section. Example usage from a regular page: - Last chapter of a comic : {{ partial "func/LastLeafSectionRecursive.html" .FirstSection }} */}} {{ if .IsPage }} {{ errorf "'func/LastLeafSectionRecursive' page argument must be a section, not a regular page" }} {{ end }} {{ $last_section := . }} {{ $sub_sections := .Sections.Reverse }} {{ if gt $sub_sections.Len 0 }} {{ $last_sub_section := index $sub_sections 0 }} {{ $last_section = partial "func/LastLeafSectionRecursive.html" $last_sub_section }} {{ end }} {{ return $last_section }}