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

Popular posts from this blog

assembly - What is the addressing mode for ld, add, and rjmp instructions? -

vowpalwabbit - Interpreting Vowpal Wabbit results: Why are some lines appended by "h"? -

Is there a way to convert an HTML page styled with Bootstrap CSS into email-compatible html? -