{{/* Check parameter type */ -}}
{{ $code := false -}}
{{ with .Get "code" -}}
  {{ $type := printf "%T" . -}}
  {{ if ne $type "bool" -}}
    {{ errorf `shortcode 'card': boolean value expected for parameter 'code', but got %s` $type -}}
  {{ else }}
    {{ $code = . -}}
  {{ end -}}
{{ end -}}

{{ $lang := default "" (.Get "lang") -}}
{{ $highlight := default "" (.Get "highlight") -}}

<div class="td-card card border me-4">
{{ with $.Get "header" -}}
    <div class="card-header{{- cond $code " code" "" -}}">
      {{ . | markdownify }}
    </div>
{{ end -}}
  <div class="card-body{{- cond $code " code p-0 m-0" "" -}}">
    {{ with $.Get "title" -}}
      <h5 class="card-title">
        {{ . | markdownify -}}
      </h5>
    {{ end -}}
    {{ with $.Get "subtitle" -}}
      <h6 class="card-title ms-2 text-body-secondary">
        {{ . | markdownify -}}
      </h6>
    {{ end -}}
    {{ with $.Inner -}}
      {{ if $code -}}
        {{ highlight . $lang $highlight -}}
      {{ else -}}
      <p class="card-text">
        {{ . -}}
      </p>
      {{ end -}}
    {{ end -}}
  </div>
  {{ with $.Get "footer" -}}
    <div class="card-footer">
      {{ . | markdownify -}}
    </div>
  {{ end -}}
</div>
