{{- define "print" -}} {{- $currentPage := . -}} {{- $populateDict := dict -}} {{- $renderPaths := slice -}} {{- range $printItem := .Params.print -}} {{- with $printItem.render.static -}} {{- $renderPaths = $renderPaths|append . -}} {{- with site.GetPage . -}} {{- $staticPage := . -}} {{- range $printer := $printItem.populate -}} {{- $section := "" -}} {{- range $populateVar, $sectionGraph := $printer -}} {{- if not $sectionGraph -}} {{- continue -}} {{- end -}} {{- if ne $populateVar "exclude" -}} {{- if hasPrefix $sectionGraph "_" -}} {{- $section = partial "GetSingularSectionName.html" (strings.TrimPrefix "_" $sectionGraph) -}} {{- else if strings.Contains $sectionGraph "_" -}} {{- $section = partial "GetSingularSectionName.html" (index (last 1 (split $sectionGraph "_")) 0) -}} {{- end -}} {{- with (index $staticPage.Params $sectionGraph) -}} {{- range $page := index $staticPage.Params $sectionGraph -}} {{- $pages := index $populateDict $populateVar| default slice -}} {{- $pages = $pages|append (printf "/%s/%s" $section $page) -}} {{- $populateDict = merge $populateDict (dict $populateVar $pages) -}} {{- end -}} {{- end -}} {{- else -}} {{- $populateDict = merge $populateDict (dict $populateVar (index $staticPage.Params $sectionGraph)) -}} {{- end -}} {{- end -}} {{- end -}} {{- end -}} {{- end -}} {{- with $printItem.render.loop -}} {{- $loopItem := . -}} {{- with (index $populateDict $loopItem) -}} {{- if not (reflect.IsSlice .) -}} {{- continue -}} {{- end -}} {{- range $pagePath := index $populateDict $loopItem -}} {{- with site.GetPage . -}} {{- $staticPage := . -}} {{- range $printer := $printItem.populate -}} {{- $section := "" -}} {{- range $populateVar, $sectionGraph := $printer -}} {{- if not $sectionGraph -}} {{- continue -}} {{- end -}} {{- if ne $populateVar "exclude" -}} {{- if hasPrefix $sectionGraph "_" -}} {{- $section = partial "GetSingularSectionName.html" (strings.TrimPrefix "_" $sectionGraph) -}} {{- else if strings.Contains $sectionGraph "_" -}} {{- $section = partial "GetSingularSectionName.html" (index (last 1 (split $sectionGraph "_")) 0) -}} {{- end -}} {{- with (index $staticPage.Params $sectionGraph) -}} {{- range $page := index $staticPage.Params $sectionGraph -}} {{- $pages := index $populateDict $populateVar| default slice -}} {{- $pages = $pages|append (printf "/%s/%s" $section $page) -}} {{- $populateDict = merge $populateDict (dict $populateVar $pages) -}} {{- end -}} {{- end -}} {{- else -}} {{- $populateDict = merge $populateDict (dict $populateVar (index $staticPage.Params $sectionGraph)) -}} {{- end -}} {{- end -}} {{- end -}} {{- end -}} {{- end -}} {{- end -}} {{- end -}} {{- with $printItem.render.loopIn -}} {{- range $printer := $printItem.populate -}} {{- $section := "" -}} {{- range $populateVar, $sectionGraph := $printer -}} {{- $populateDict = merge $populateDict (dict $populateVar $sectionGraph) -}} {{- end -}} {{- end -}} {{- $loopParts := split . "." -}} {{- $loopIn := index $loopParts 0 -}} {{- $loopOut := index $loopParts 1 -}} {{- range $i, $page := (index $populateDict $loopIn) -}} {{- $loopInKey := (printf "%s_%d" $loopIn $i) -}} {{- $pages := index $populateDict $loopInKey| default slice -}} {{- with site.GetPage $page -}} {{- $pages = $pages|append $page -}} {{- end -}} {{- $populateDict = merge $populateDict (dict $loopInKey $pages) -}} {{- end -}} {{- end -}} {{- with $printItem.render.loopOut -}} {{- $loopParts := split . "." -}} {{- $loopIn := index $loopParts 1 -}} {{- $loopOut := index $loopParts 0 -}} {{- range $outI, $outPage := (index $populateDict $loopIn) -}} {{- with $page := site.GetPage $outPage -}} {{- $sectionGraph := index $populateDict $loopOut -}} {{- range $inI, $inPage := (index $page.Params $sectionGraph) -}} {{- $section := "" -}} {{- if hasPrefix $sectionGraph "_" -}} {{- $section = partial "GetSingularSectionName.html" (strings.TrimPrefix "_" $sectionGraph) -}} {{- else if strings.Contains $sectionGraph "_" -}} {{- $section = partial "GetSingularSectionName.html" (index (last 1 (split $sectionGraph "_")) 0) -}} {{- end -}} {{- $key := (printf "%s_%d" $loopIn $outI) -}} {{- $pages := index $populateDict $key | default slice -}} {{/*- with site.GetPage $inPage -*/}} {{- $pages = $pages|append (printf "/%s/%s" $section $inPage) -}} {{/*- end -*/}} {{- $populateDict = merge $populateDict (dict $key $pages) -}} {{- end -}} {{- end -}} {{- end -}} {{- end -}} {{- end -}}

{{- printf "Populate dict: %s" $populateDict -}}

{{- printf "Render paths: %s" $renderPaths -}}

{{- end -}}