diff options
| author | Corné Haasjes <c.haasjes@lumc.nl> | 2025-04-01 19:38:31 +0200 | 
|---|---|---|
| committer | Corné Haasjes <c.haasjes@lumc.nl> | 2025-04-01 19:38:31 +0200 | 
| commit | b8715b0cf2a4a371c45703704da9d8232f6cf907 (patch) | |
| tree | e92b292c8ba5a1d55bf2918bbedc4c9698ebd796 /layouts/partials/functions | |
| parent | 9794243a3ff85aae024d6a8f7439702cc66f3f73 (diff) | |
Add support for hooks in layouts/partials/hooks
Supported hooks:
- head_start
- head_end
- body_end
- footer_start
Diffstat (limited to 'layouts/partials/functions')
| -rw-r--r-- | layouts/partials/functions/get_hook.html | 23 | 
1 files changed, 23 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..79c9987 --- /dev/null +++ b/layouts/partials/functions/get_hook.html @@ -0,0 +1,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 }}
\ No newline at end of file | 
