{{- $page := .page }} {{- $class := .class | default "" }} {{- $href := (trim .href " ") | default "" }} {{- $onempty := cond (isset . "onempty") .onempty "disable" }} {{- $onwidths := cond (isset . "onwidths") .onwidths "show" }} {{- $onwidthm := cond (isset . "onwidthm") .onwidthm "show" }} {{- $onwidthl := cond (isset . "onwidthl") .onwidthl "show" }} {{- $attributes := .attributes | default dict }} {{- $type := .type | default "" }} {{- $title := (trim .title " ") | default "" }} {{- $hint := (trim .hint " ") | default "" }} {{- $icon := (trim .icon " ") | default "" }} {{- if and $icon (not (findRE ".*?\\bfa-\\w.*?" $icon)) }} {{- $icon = printf "fa-fw fas fa-%s" $icon }} {{- end }} {{- $content := .content }} {{- $isDisabled := not $href }} {{- $isButton := false }} {{- if or (not $href) (strings.HasPrefix $href "javascript:") }} {{- $isButton = true }} {{- $href = substr $href (len "javascript:") }} {{- if not $type }} {{- $type = "button" }} {{- end }} {{- else }} {{- $u := urls.Parse .href }} {{- if $u.IsAbs }} {{- partialCached "_relearn/urlExists.gotmpl" (dict "url" .href "page" $page "type" "link") $u.String }} {{- else }} {{- $linkObject := partial "_relearn/linkObject.gotmpl" (dict "url" .href "page" $page) }} {{- if $linkObject }} {{- $href = partial "_relearn/decoratedLink.gotmpl" (dict "url" .href "page" $page "linkObject" $linkObject "param" "link") }} {{- else }} {{- $filepath := "[virtual file]" }}{{ with and $page $page.File $page.File.Filename }}{{ $filepath = . }}{{ end }} {{- $msg := printf "%q: link '%s' is not a page or a resource" $filepath .href }} {{- partial "_relearn/urlErrorReport.gotmpl" (dict "url" .href "page" $page "param" "link" "msg" $msg) }} {{- end }} {{- end }} {{- $attributes = merge $attributes (partial "_relearn/linkAttributes.gotmpl" (dict "url" $href "page" $page "attributes" (dict "class" "topbar-control" "title" $hint))) -}} {{- end }}
{{- if $isDisabled -}} {{- else if $isButton -}} {{- else -}} {{- end }} {{- if $content }}
{{- $content }}
{{- end }}