diff options
Diffstat (limited to 'layouts/partials/functions/get_hook.html')
-rw-r--r-- | layouts/partials/functions/get_hook.html | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/layouts/partials/functions/get_hook.html b/layouts/partials/functions/get_hook.html new file mode 100644 index 0000000..3e6b4fb --- /dev/null +++ b/layouts/partials/functions/get_hook.html @@ -0,0 +1,19 @@ +{{/* + Customize layouts without overwriting files. + Hooks should be defined in the layouts/partials/hooks directory. + + Parameters: + - hook: The name of the hook to be used. + - context: The context to be passed to the partial. +*/}} + +{{ $hook := .hook }} +{{ $context := .context }} + +{{ if not (hasSuffix $hook ".html") }} + {{ $hook = printf "%s.html" $hook }} +{{ end }} + +{{ if fileExists (path.Join "layouts/partials/hooks" $hook) }} + {{ partial (path.Join "hooks" $hook) $context }} +{{ end }}
\ No newline at end of file |