I have an []struct that can have no content but also it is possible that it has content:
Anleitung []struct {
Name string `json:"blog"`
Link string `json:"link"`
} `json:"anleitung"`
In my template I try to check if Anleitung contains something, and only then proceed:
{{ ne $jb.Anleitung "" }}
<div class="btn-group">
<button type="button" class="btn btn-info dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
<span class="badge">4</span> Anleitungen <span class="caret"></span>
</button>
<ul class="dropdown-menu">
{{ range $anl := $jb.Anleitung }}
<li><a href="{{ $anl.Link }}?ref=jbguide">{{ $anl.Name }}</a></li>
{{ end }}
</ul>
</div>
{{ end }}
compiling the whole thing gives me the following error:
Error rendering
index
template: template: index.tmpl:131: unexpected {{end}}
Row no 131 is the last row in the template file.
Is there a way to check if the []struct contains any data?