It looks like the function first
does not work.
"source": {
"name": "MV",
"count": "{{len .data}}",
"val" : [
{{ range $index, $e := first 3 .data }}
{{ if $index }}, {{end}}
{"aid": "{{ $e.aid}}", "vid": "{{ $e.vid}}" }
{{ end }}
]
}
When I remove first n
(where n is a number less than total) it works. There are 9 elements.
As an alternative I can check if index is first element but that will be slower in performance, plus more verbose.
{{ if eq $index 0 }}
{"aid": "{{$index}} - {{ $e.aid}} ", "vid": "{{ $e.vid}}" }
{{end}}
Looks like there is no support for a lot of these functions.