26 lines (24 loc) · 948 B
 1{{- $key  := .Get 0 -}}
 2{{- $val  := .Get 1 | default "" -}}
 3{{- $arg3 := .Get 2 -}}  {{/* used as href OR as date format (see below) */}}
 4{{- $href := $arg3 -}}
 5
 6{{- /* If value is the literal "date", render build time instead. */ -}}
 7{{- if eq (lower $val) "date" -}}
 8  {{- $fmt := "2006-01-02" -}}  {{/* default format */}}
 9  {{- /* If the 3rd param doesn't look like a URL, treat it as a format string. */ -}}
10  {{- if $arg3 -}}
11    {{- if not (in $arg3 "://") -}}
12      {{- $fmt = $arg3 -}}
13      {{- $href = "" -}}       {{/* it's a format, not a link */}}
14    {{- end -}}
15  {{- end -}}
16  {{- $val = (now | time.Format $fmt) -}}
17{{- end -}}
18
19<div class="ff-line">
20  <span class="ff-key">{{ $key }}</span><span class="ff-colon">:</span>
21  {{- if $href -}}
22    <a class="ff-val" href="{{ $href | safeURL }}" target="_blank" rel="noopener noreferrer">{{ $val }}</a>
23  {{- else -}}
24    <span class="ff-val">{{ $val }}</span>
25  {{- end -}}
26</div>