2

in my controller i set the following data:

c.Data["foos"] = foos

and

c.Data["user"] = user

So if I ask some property from user in the view, all fine.

{{if .user.IsSuperUser}}
    <th>ID</th>
    <th>Username</th>
{{end}}

But in:

<tbody>
{{range $foo := .foos}}
   <tr>
   {{if .user.IsSuperUser}}
      <td>xyz</td>
      <td>abc</td>
   {{end}}
...

myBeego:template: foo/foos.tpl:56:46: executing "content" at <.user.IsSuperUser>: user is not a field of struct type *models.Foo

How can I handle that?

Thanks for every help and happy Thanksgiving.

user1644033
  • 277
  • 5
  • 17

1 Answers1

3

I found this nice little link: In a template how do you access an outer scope while inside of a "with" or "range" scope?

{{with .Inner}}
  Outer: {{$.OuterValue}}
  Inner: {{.InnerValue}}
{{end}}

That's it. :)

Community
  • 1
  • 1
user1644033
  • 277
  • 5
  • 17