{{ $slice := .xxx }}
{{ $divs := newScratch }}
{{ range $slice }}
{{ $id := printf "tag-check-%s" . }}
{{ $input := partial "functions/area_element_style/base/input" (dict "type" "checkbox" "class" "btn-check" "name" "tag_name" "value" . "id" $id) }}
{{ $label := partial "functions/area_element_style/base/label" (dict "innerHTML" . "class" "btn" "for" $id) }}
{{ $div_inner := printf "%s%s" $input $label }}
{{ $div := partial "functions/area_element_style/base/div" (dict "innerHTML" $div_inner "class" "btn-group btn-group-sm") }}
{{ $divs.Add "html" $div | safeHTML }}
{{ end }}
{{ return $divs.Get "html" }}
{{ $slice := .xxx }}
{{/*{{ $divs := newScratch }}*/}}
{{ $divs := "" }}
{{ range $slice }}
{{ $id := printf "tag-check-%s" . }}
{{ $input := partial "functions/area_element_style/base/input" (dict "type" "checkbox" "class" "btn-check" "name" "tag_name" "value" . "id" $id) }}
{{ $label := partial "functions/area_element_style/base/label" (dict "innerHTML" . "class" "btn" "for" $id) }}
{{ $div_inner := printf "%s%s" $input $label }}
{{ $div := partial "functions/area_element_style/base/div" (dict "innerHTML" $div_inner "class" "btn-group btn-group-sm") }}
{{/* {{ $divs.Add "html" $div | safeHTML }}*/}}
{{ $divs = $div }}
{{ end }}
{{/*{{ return $divs.Get "html" }}*/}}
{{ return $divs }}
The first code returns the desired code, but some special symbols are escaped, such as angle brackets <>,
The way the second piece of code is written, only the last content of the range loop is returned. The good thing is that no special characters are escaped.
How can I safely output html characters through return?