|
1 | | -{{- /* Handle different versions of booleans */ -}} |
2 | | -{{ $showAsCards := .Get 0 | default (.Get "showAsCards") | default "false"}} |
| 1 | +{{ $title := .Get "title" }} |
| 2 | +{{ $showAsCardsParam := .Get "showAsCards" | default "false"}} |
3 | 3 | {{- /* Validate the parameter strictly */ -}} |
4 | | -{{ if not (in (slice "true" "false") $showAsCards) }} |
5 | | - {{ warnf "The '<card-section>' Shortcode parameter 'showAsCards' must be 'true' or 'false', but got: '%s'. This will now default to 'false'" $showAsCards}} |
6 | | -{{ end }} |
| 4 | +{{- if not (in (slice "true" "false") $showAsCardsParam) -}} |
| 5 | + {{- warnf "The '<card-section>' Shortcode parameter 'showAsCards' must be 'true' or 'false', but got: '%s'. This will now default to 'false'" $showAsCardsParam -}} |
| 6 | +{{- end -}} |
| 7 | +{{- $showAsCards := cond (eq $showAsCardsParam "true") "true" "false" -}} |
7 | 8 | {{- $current := .Page.Scratch.Get "showAsCards" | default (dict) -}} |
8 | | -{{- $newShowAsCards := dict (.Get "title" | default "main") ($showAsCards) -}} |
| 9 | +{{- $newShowAsCards := dict ($title | default "main") ($showAsCards) -}} |
9 | 10 | {{- .Page.Scratch.Set "showAsCards" (merge $current ($newShowAsCards)) -}} |
10 | | -{{ $class := "card-grid wide"}} |
| 11 | +{{- $class := "card-grid wide" -}} |
11 | 12 | {{- /* Validate that the parent is card-layout */ -}} |
12 | 13 | {{ if eq .Parent.Name "card-layout"}} |
13 | 14 | <div class="card-section" data-mf="true" style="display: none;"> |
14 | | - {{- if .Get "title" -}} |
15 | | - <strong class="card-section-title">{{- .Get "title" -}}</strong> |
| 15 | + {{- if $title -}} |
| 16 | + <strong class="card-section-title">{{- $title -}}</strong> |
16 | 17 | <div class="card-section-content{{ if eq $showAsCards "true" }} {{ $class }} {{ end }}">{{- .Inner -}}</div> |
17 | 18 | {{ end }} |
18 | 19 | </div> |
19 | 20 | <div class="row" data-mf="false"> |
20 | | - {{- if .Get "title" -}} |
21 | | - <strong class="card-section-title">{{- .Get "title" -}}</strong> |
| 21 | + {{- if $title -}} |
| 22 | + <strong class="card-section-title">{{- $title -}}</strong> |
22 | 23 | <div class="card-section-content{{ if eq $showAsCards "true" }} {{ $class }} {{ end }} card-deck">{{- .Inner -}}</div> |
23 | 24 | {{ end }} |
24 | 25 | </div> |
|
0 commit comments