{{- $input := . -}} {{- $context := collections.Dictionary -}} {{- $config := site.Params.ananke.hooks | compare.Default (collections.Dictionary) -}} {{- $disableMessages := $config.disable_messages | compare.Default (collections.Slice) -}} {{- $colourHook := "\033[38;2;170;153;255m" -}} {{- $colourUnused := "\033[38;2;204;119;102m" -}} {{- $colourReset := "\033[0m" -}} {{- $hookSlug := "FILTER" -}} {{- if reflect.IsMap . -}} {{- with collections.Index . "__ananke_hook_slug" -}} {{- $hookSlug = . -}} {{- end -}} {{- with collections.Index . "__ananke_hook_input" -}} {{- $input = . -}} {{- end -}} {{- end -}} {{- if reflect.IsMap $input -}} {{- $context = collections.Merge $context $input -}} {{- $context = collections.Merge $context (collections.Dictionary "type" "full") -}} {{- partials.Include "func/debug-cli.html" (collections.Dictionary "message" (fmt.Printf "%s>>> %s: %s%s" $colourHook $hookSlug $context.hook $colourReset) "severity" "info" ) -}} {{- partials.Include "func/debug-cli.html" (collections.Dictionary "message" "hook is extended" "severity" "debug" ) -}} {{- else -}} {{- $context = collections.Merge $context (collections.Dictionary "hook" $input "context" (collections.Dictionary) "type" "simple" ) -}} {{- partials.Include "func/debug-cli.html" (collections.Dictionary "message" (fmt.Printf "%s>>> %s: %s%s" $colourHook $hookSlug $context.hook $colourReset) "severity" "info" ) -}} {{- partials.Include "func/debug-cli.html" (collections.Dictionary "message" "hook is simple" "severity" "debug" ) -}} {{- end -}} {{- partials.Include "func/hooks/collector.html" (collections.Dictionary "hook" $context.hook "context" $context ) -}} {{- $loaded := false -}} {{- $output := "" -}} {{- $partialName := fmt.Printf "hooks/%s.html" $context.hook -}} {{- $partialHook := fmt.Printf "_partials/%s" $partialName -}} {{- partials.Include "func/debug-cli.html" (collections.Dictionary "message" (fmt.Printf "partial Name: %s" $partialName) "severity" "debug" ) -}} {{- $cache := false -}} {{- with $context.cache -}} {{- $cache = . -}} {{- else -}} {{- with $context.cached -}} {{- $cache = . -}} {{- end -}} {{- end -}} {{- if templates.Exists $partialHook -}} {{- if compare.Eq true $cache -}} {{- $output = partials.IncludeCached $partialName $context.context $context.hook -}} {{- partials.Include "func/debug-cli.html" (collections.Dictionary "message" "included cached" "severity" "debug" ) -}} {{- $loaded = true -}} {{- else -}} {{- $output = partials.Include $partialName $context.context -}} {{- partials.Include "func/debug-cli.html" (collections.Dictionary "message" "included uncached" "severity" "debug" ) -}} {{- $loaded = true -}} {{- end -}} {{- end -}} {{- if compare.Eq $loaded false -}} {{- if not (collections.In $disableMessages "unused_hooks") -}} {{- partials.Include "func/debug-cli.html" (collections.Dictionary "message" (fmt.Printf "%s<<< %s: `%s` %sunused%s" $colourHook $hookSlug $context.hook $colourUnused $colourReset) "context" $input "severity" "info" ) -}} {{- end -}} {{- else -}} {{- partials.Include "func/debug-cli.html" (collections.Dictionary "message" (fmt.Printf "%s<<< %s: %s done%s" $colourHook $hookSlug $context.hook $colourReset) "severity" "info" ) -}} {{- end -}} {{- return $output -}}