Files
hinode/layouts/shortcodes/img.html
2024-01-01 12:32:39 +01:00

44 lines
1.6 KiB
HTML

<!--
Copyright © 2024 The Hinode Team / Mark Dumay. All rights reserved.
Use of this source code is governed by The MIT License (MIT) that can be found in the LICENSE file.
Visit gethinode.com/license for more details.
-->
{{ $error := false -}}
<!-- Validate arguments -->
{{ if partial "utilities/IsInvalidArgs.html" (dict "structure" "carousel-item" "args" .Params "group" "shortcode" ) }}
{{ errorf "Invalid arguments: %s" .Position -}}
{{ $error = true }}
{{ end }}
<!-- Initialize arguments -->
{{ if not .Parent }}
{{ errorf "The img shortcode should be contained within a carousel shortcode: %s" .Position }}
{{ else if not $error }}
{{- $src := .Get "src" | default "" -}}
{{- $caption := .Get "caption" | default "" -}}
{{- $ratio := partial "utilities/GetArgParent" (dict "page" . "arg" "ratio") -}}
{{- $portrait := partial "utilities/GetArgParent" (dict "page" . "arg" "portrait") | default false -}}
{{- $active := .Get "active" | default (eq .Ordinal 0) -}}
{{- $loading := .Get "loading" | default "eager" -}}
<!-- Main code -->
{{- $output := partial "assets/carousel-item.html" (dict
"page" .Page
"active" $active
"src" $src
"caption" $caption
"ratio" $ratio
"portrait" $portrait
"loading" $loading
) }}
{{ $current := .Parent.Scratch.Get "inner" }}
{{ if $current }}
{{ .Parent.Scratch.Set "inner" (print $current $output) }}
{{ else }}
{{ .Parent.Scratch.Set "inner" $output }}
{{ end }}
{{ end -}}