summaryrefslogtreecommitdiff
path: root/layouts/partials/functions/get_hook.html
blob: 79c99876481764520963162492f149f16e3c73f3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
{{/* 
    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 }}
{{ $hookName := $hook.Name }}
{{ $hookType := $hook.Type }}

{{ if not (hasSuffix $hook ".html") }}
    {{ $hook = printf "%s.html" $hook }}
{{ end }}

{{ $hook_path := path.Join "layouts/partials/hooks" $hook }}

{{ if fileExists $hook_path }}
    {{ partial $hook_path $context }}
{{ end }}