mirror of
https://github.com/gethinode/hinode.git
synced 2025-10-15 22:13:09 +00:00
68 lines
2.1 KiB
HTML
68 lines
2.1 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" "image" "child" "nav-item" "args" .Params "group" "shortcode") }}
|
|
{{ errorf "Invalid arguments: %s" .Position -}}
|
|
{{ $error = true }}
|
|
{{ end }}
|
|
|
|
<!-- Initialize arguments -->
|
|
{{- $url := "" -}}
|
|
{{- $ratio := "" -}}
|
|
{{- $wrapper := "" -}}
|
|
{{- $class := "" -}}
|
|
{{- $title := "" -}}
|
|
{{- $caption := "" -}}
|
|
{{- $figclass := "" -}}
|
|
{{- $mode := false -}}
|
|
{{- $portrait := false -}}
|
|
{{- $loading := "" -}}
|
|
{{- $error := false -}}
|
|
{{- $plain := false -}}
|
|
|
|
{{- if .IsNamedParams -}}
|
|
{{ $url = .Get "src" | default "" -}}
|
|
{{ $url = .Get "url" | default $url -}}
|
|
{{ $ratio = .Get "ratio" | default "" -}}
|
|
{{- $class = .Get "class" | default "" -}}
|
|
{{- $wrapper = .Get "wrapper" | default "" -}}
|
|
{{- $loading = .Get "loading" | default "" -}}
|
|
{{ $title = .Get "title" | default "" -}}
|
|
{{ $caption = .Get "caption" | default "" -}}
|
|
{{ $figclass = .Get "figclass" | default "" -}}
|
|
{{ with .Get "mode" }}{{ $mode = partial "utilities/CastBool.html" . }}{{ end -}}
|
|
{{ with .Get "portrait" }}{{ $portrait = partial "utilities/CastBool.html" . }}{{ end -}}
|
|
{{ with .Get "plain" }}{{ $plain = partial "utilities/CastBool.html" . }}{{ end -}}
|
|
{{ else -}}
|
|
{{ $url = .Get 0 }}
|
|
{{ end -}}
|
|
|
|
{{ if not $url }}
|
|
{{ errorf "Missing value for param 'src': %s" .Position -}}
|
|
{{- $error = true -}}
|
|
{{ end }}
|
|
|
|
<!-- Main code -->
|
|
{{- if not $error -}}
|
|
{{- partial "assets/image.html" (dict
|
|
"url" $url
|
|
"ratio" $ratio
|
|
"wrapper" $wrapper
|
|
"class" $class
|
|
"title" $title
|
|
"caption" $caption
|
|
"figclass" $figclass
|
|
"mode" $mode
|
|
"portrait" $portrait
|
|
"plain" $plain
|
|
"loading" $loading
|
|
"page" .Page)
|
|
-}}
|
|
{{- end -}}
|