I currently use revel as underlying webframework. My template/logic is very basic. I fetch a []*someObject from the database and want to display it in a table.
{{ if .objs}}
{{ range .objs }}
<tr>
<td><span>{{ .Title }}</span></td>
<td>x</td>
<td>y</td>
{{ $id := .Id}}
<td><a href="{{url "ObjectController.ViewObj" .Id}}">View {{ $id }}</a></td>
</tr>
{{ end }}
{{ end }}
This however produces a "template runtime error, index out of range" with no further information. The Problem is the url part.
{{url "ObjectController.ViewObj"}}
Works. Without additional .Id
it's perfectly fine, but since I want to pass the id into the url this is not an option.
The route is:
/lobby/view/:objid ObjectController.View
EDIT(FIXED): Apparently I forgot to add id as parameter:
func (c ObjectController) View(id int64) revel.Result
I did not know that it throws such an error, I would expect a more specific error.