Go template checking for current page for nav bar -
Go template checking for current page for nav bar -
i'm trying set li in golang template active based on current page. i've read can {{if .scoreheader}} check existence of variable. there way around this?
<div class="col-md-3"> <ul class="nav nav-pills nav-stacked"> {{range $id, $name := .test}} {{if $name == .scoreheader}} <li class="active"> {{else}} <li> {{end}} <li><a href="/app/index/?company={{$id}}">{{$name}}</a></li> {{end}} </ul> </div>
you can utilize eq function explained in text/template:
there set of binary comparing operators defined functions:
eq returns boolean truth of arg1 == arg2
so if-statement be:
{{if eq $name $.scoreheader}} go
Comments
Post a Comment