|
1 |
| -{{ $class := .Get 0 }} |
| 1 | +{{ $class := .Get 0 | default (.Get "class") | default "" }} |
| 2 | +{{ $title := .Get 1 | default (.Get "title") | default "" }} |
| 3 | +{{ $icon := .Get 2 | default (.Get "icon") | default "" }} |
| 4 | + |
| 5 | +{{/* Handle different versions of booleans */}} |
| 6 | +{{ $inlineParam := (.Get 3) | default (.Get "inline") | default "false" | lower }} |
| 7 | +{{- /* Validate the parameter strictly */ -}} |
| 8 | +{{ if not (in (slice "true" "false") $inlineParam) }} |
| 9 | + {{ warnf "The '<call-out>' Shortcode parameter 'inline' must be 'true' or 'false', but got: '%s'. This will now default to 'false'" $inlineParam}} |
| 10 | +{{ end }} |
| 11 | + |
| 12 | +{{ $inline := eq $inlineParam "true" }} |
| 13 | + |
2 | 14 | {{ $sideOption := "side-callout" }}
|
3 | 15 | {{ $inlineOption := "inline-callout" }}
|
4 | 16 |
|
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 }} |
| 17 | +{{ if $inline }} |
| 18 | + {{ $class = printf "%s %s" $class $inlineOption }} |
| 19 | +{{ else }} |
| 20 | + {{ $class = printf "%s %s" $class $sideOption }} |
8 | 21 | {{ end }}
|
9 | 22 |
|
10 | 23 | <!-- Blockquote element with a class that is the first parameter passed to the shortcode -->
|
11 | 24 | <blockquote class="{{ $class }}">
|
12 | 25 | <div>
|
13 | 26 | <!-- Check if the third parameter (icon class) is provided -->
|
14 |
| - {{ with .Get 2 }} |
| 27 | + {{ with $icon }} |
15 | 28 | <!-- If the icon class is provided, render an <i> element with the given class -->
|
16 | 29 | <i class="{{ . }}"></i>
|
17 | 30 | {{ end }}
|
18 | 31 | <!-- Render the second parameter (title) as a strong element -->
|
19 |
| - <strong>{{ .Get 1 }}</strong><br/> |
| 32 | + <strong>{{ $title }}</strong><br/> |
20 | 33 | <!-- Render the inner content of the shortcode, converting it from Markdown to HTML -->
|
21 | 34 | {{ .Inner | markdownify }}
|
22 | 35 | </div>
|
|
0 commit comments