1
- {{ $class := .Get 0 }}
1
+ {{/*
2
+
3
+ Usage:
4
+ {{< call-out title ="Custom title " icon ="fa fa-check-circle " inline ="true "> }}
5
+ This callout uses the icon check-circle. **This should be an inline callout.**
6
+ {{</ call-out > }}
7
+
8
+ Backwards compatibility usage:
9
+ {{< call-out "warning" "Custom title""fa fa-check-circle" "true"> }}
10
+ This callout uses the icon check-circle. **This should be an inline callout.**
11
+ {{</ call-out > }}
12
+
13
+ Depends on `callout.html` partial.
14
+
15
+ */}}
16
+
17
+ {{ $class := .Get 0 | default (.Get "class") | default "" }}
18
+ {{ $title := .Get 1 | default (.Get "title") | default "" }}
19
+ {{ $icon := .Get 2 | default (.Get "icon") | default "" }}
20
+
21
+ {{/* Handle different versions of booleans */}}
22
+ {{ $inlineParam := (.Get 3) | default (.Get "inline") | default "false" | lower }}
23
+ {{- /* Validate the parameter strictly */ -}}
24
+ {{ if not (in (slice "true" "false") $inlineParam) }}
25
+ {{ warnf "The '< call-out > ' Shortcode parameter 'inline' must be 'true' or 'false', but got: '%s'. This will now default to 'false'" $inlineParam}}
26
+ {{ end }}
27
+
28
+ {{ $inline := eq $inlineParam "true" }}
29
+
2
30
{{ $sideOption := "side-callout" }}
3
31
{{ $inlineOption := "inline-callout" }}
4
32
5
- <!-- Add default option for callouts that are "sideline" if one is not provided -->
6
- {{ if and (not (strings.Contains $class $sideOption)) (not (strings.Contains $class $inlineOption)) }}
7
- {{ $class = printf "%s %s" $class $sideOption }}
33
+ {{ if $inline }}
34
+ {{ $class = printf "%s %s" $class $inlineOption }}
35
+ {{ else }}
36
+ {{ $class = printf "%s %s" $class $sideOption }}
8
37
{{ end }}
9
38
10
- <!-- Blockquote element with a class that is the first parameter passed to the shortcode -->
11
- < blockquote class ="{{ $class }} ">
12
- < div >
13
- <!-- Check if the third parameter (icon class) is provided -->
14
- {{ with .Get 2 }}
15
- <!-- If the icon class is provided, render an <i> element with the given class -->
16
- < i class ="{{ . }} "> </ i >
17
- {{ end }}
18
- <!-- Render the second parameter (title) as a strong element -->
19
- < strong > {{ .Get 1 }}</ strong > < br />
20
- <!-- Render the inner content of the shortcode, converting it from Markdown to HTML -->
21
- {{ .Inner | markdownify }}
22
- </ div >
23
- </ blockquote >
39
+ {{ partial "callout.html" (dict
40
+ "class" $class
41
+ "title" $title
42
+ "icon" $icon
43
+ "inline" $inline
44
+ "content" .Inner
45
+ ) }}
0 commit comments