Raw
 1{{- $renderPaths := slice -}}
 2{{- $collectDict := dict -}}
 3
 4{{- range $printItem := .Params.print -}}
 5
 6    {{- if $printItem.from -}}{{- $pagePaths := slice -}}
 7        {{- with site.GetPage $printItem.from -}}
 8            {{- $from := .Path -}}
 9            {{- $renderPaths = ($renderPaths | append $from) | uniq -}}
10            {{- $pagePaths = slice $from -}}
11
12            {{- with $printItem.follow -}}
13                {{- $currentSet := slice $from -}}
14                {{- range $hop := . -}}
15                    {{- $nextSet := slice -}}
16                    {{- range $pagePath := $currentSet -}}
17                        {{- with site.GetPage $pagePath -}}
18                            {{- $nextSet = ($nextSet | append $pagePath) | uniq -}}
19                            {{- $children := partial "GetPagePathsFromParam.html" (dict "page" . "param" $hop) -}}
20                            {{- range $child := $children -}}
21                                {{- $nextSet = ($nextSet | append $child) | uniq -}}
22                            {{- end -}}
23                        {{- end -}}
24                    {{- end -}}
25                    {{- $currentSet = $nextSet -}}
26                {{- end -}}
27                {{- $pagePaths = $currentSet -}}
28                {{- $renderPaths = ($renderPaths | append $pagePaths) | uniq -}}
29            {{- end -}}
30
31            {{- with $printItem.collect -}}
32                {{- range $name, $param := . -}}
33                    {{- $collected := index $collectDict $name | default slice -}}
34                    {{- range $pagePath := $pagePaths -}}
35                        {{- with site.GetPage $pagePath -}}
36                            {{- $paths := partial "GetPagePathsFromParam.html" (dict "page" . "param" $param) -}}
37                            {{- range $p := $paths -}}
38                                {{- $collected = ($collected | append $p) | uniq -}}
39                            {{- end -}}
40                        {{- end -}}
41                    {{- end -}}
42                    {{- $collectDict = merge $collectDict (dict $name $collected) -}}
43                {{- end -}}
44            {{- end -}}
45
46        {{- else -}}
47            {{- warnf "print: page not found: %s" $printItem.from -}}
48        {{- end -}}
49
50    {{- else if $printItem.emit -}}{{- $pages := index $collectDict $printItem.emit -}}
51        {{- with $pages -}}
52            {{- $renderPaths = ($renderPaths | append .) | uniq -}}
53        {{- else -}}
54            {{- warnf "print: emit key not found: %s" $printItem.emit -}}
55        {{- end -}}
56
57    {{- end -}}
58
59{{- end -}}
60{{- return $renderPaths -}}