You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to golang-nuts
I have a template which iterates over []DataStruct. In my template I
have something like the following:
{{range data}}
<p id="p_{{count}} />
{{end}}
I want to generate an ID that is based on an integer that increases
with each iteration of the range. I've read the template documentation
but couldn't find anything that suggests a built-in way to do this,
and using {{$counter := $counter + 1}} spat out an error about the "+"
symbol. The only course of action I can think of is to map a function
that increments a value: {{$counter := Increment $counter}} or
something.
Can anyone think of a better way to do this?
Cheers!
Ben
Andrew Gerrand
unread,
Mar 8, 2012, 7:08:01 AM3/8/12
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message