I am trying to compare the length of a list in golang html/template. But it is loading forever in html.
{{ $length := len .SearchData }} {{ if eq $length "0" }}
Sorry. No matching results found
{{ end }}
Could anyone help me with this?
I am trying to compare the length of a list in golang html/template. But it is loading forever in html.
{{ $length := len .SearchData }} {{ if eq $length "0" }}
Sorry. No matching results found
{{ end }}
Could anyone help me with this?
There is {{ else }} for {{ range }} Works well for maps as well https://play.golang.org/p/7xJ1LXL2u09:
{{range $item := . }}
<span>{{ $item }}</span>
{{ else }}
<span>Sorry no rows here</span>
{{ end }}