{{- $val := .val -}}
{{- $item := "" -}}
{{- $count := 0 -}}
{{- if $val -}}
  {{- $parts := split $val ":" -}}
  {{- $item = index $parts 0 -}}
  {{- if gt (len $parts) 1 -}}
    {{- $count = int (index $parts 1) -}}
  {{- end -}}
{{- end -}}

{{- $img := "" -}}
{{- if $item -}}
  {{- $img = resources.Get (printf "items/%s.png" $item) -}}
{{- end -}}

<div class="sfc-slot sfc-{{ .cls }}"
     style="left: {{ .x }}; top: {{ .y }};"
     {{ with $item }}data-name="{{ . }}"{{ end }}>
  {{- if $img -}}
    <img class="sfc-item" src="{{ $img.RelPermalink }}"
         alt="{{ $item }}" loading="lazy">
    {{- if gt $count 1 -}}
      <span class="sfc-count">{{ $count }}</span>
    {{- end -}}
  {{- else if $item -}}
    <span class="sfc-missing" title="未找到 assets/items/{{ $item }}.png">?</span>
  {{- end -}}
</div>
