If I use i18n statement in range statement, I got a template Execute err. But I move the i18n statement outside the range statement. It's OK. The error message is:
[D] [controller.go:283] template Execute err: template: userscontroller/get.tpl:16:244: executing "userscontroller/get.tpl" at <.Lang>: can't evaluate field Lang in type models.Account
[E] [server.go:2694] template: userscontroller/get.tpl:16:244: executing "userscontroller/get.tpl" at <.Lang>: can't evaluate field Lang in type models.Account
This is my sample code:
<ul class="w3-ul" id="UserList">
{{range $index, $user := .Users}}
<li class="w3-bar w3-hover-light-blue {{if eq $user.Role 1}}w3-pale-green{{end}} {{if eq $user.Role 2}}w3-pale-blue{{end}}{{if eq $user.Role 3}}w3-pale-red{{end}}" onclick="openProfile(this,{{$user.Uid}})">
<div class="w3-bar-item">
{{if eq $user.Role 1}}<span class="w3-large" style="color:green; font-weight: bold;">{{i18n .Lang ".users.administrator"}}</span>{{end}}{{if eq $user.Role 2}}<span class="w3-large" style="color:blue; font-weight: bold;">{{i18n .Lang ".users.user"}}</span>{{end}}{{if eq $user.Role 3}}<span class="w3-large" style="color:red; font-weight: bold;">{{i18n .Lang ".users.inactivated"}}</span>{{end}}<span class="w3-large Last">{{$user.Last}}</span> <span class="w3-large First">{{$user.First}}</span><br>
<span>{{i18n .Lang ".users.email"}}</span><span class="Email">{{$user.Email}}</span>
</div>
</li>
{{end}}
</ul>
Has anyone encountered a similar problem? How to solve it, thank you.