loopIN/OUT mess...

This commit is contained in:
Marcell Mars 2025-05-11 07:19:46 +02:00
parent 98da65bb20
commit fc09b7e842
2 changed files with 119 additions and 24 deletions

View file

@ -1,31 +1,119 @@
{{- define "print" -}}
{{- $currentPage := . -}}
{{- range $source := $currentPage.Params.print[0].render.static -}}
{{- with site.GetPage (printf "%s" $source) -}}
{{- $sourcePage := . -}}
{{- partial "single-page-graph.html" . -}}
{{- partial "page-header.html" . -}}
<main class="content">
<div class="title"><span class="supt">{{ $sourcePage.Section }}</span>{{ $sourcePage.Title }}</div>
<div class="page-menu">
<aside class="toc">
{{ if ne (trim $sourcePage.TableOfContents "\n") "<nav id=\"TableOfContents\"></nav>" }}
{{ $sourcePage.TableOfContents }}
{{ end }}
</aside>
<aside class="graph-menus">
{{- partial "menu_verbs.html" . -}}
{{- partial "deferred_page_graph.html" . -}}
</aside>
</div>
<div class="article">{{ $sourcePage.Content }}</div>
</main>
{{- range $param := $currentPage.Params.print.iterate -}}
{{- printf "Iterate params: %#v" . -}}
{{- with index $sourcePage.Params $param -}}
{{- printf "Iteration: %#v" . -}}
{{- $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 -}}
<p>{{- printf "Populate dict: %s" $populateDict -}}</p>
<p>{{- printf "Render paths: %s" $renderPaths -}}</p>
{{- end -}}

7
static/js/paged.min.js vendored Normal file

File diff suppressed because one or more lines are too long