I would like to use a js variable in a go block within a template. Here is where i set the variable :
{{ range $tourneyNo, $tourney := . }}
<ul><strong>Numéro du tournoi : {{ $tourneyNo }}</strong>:</ul>
<script type="text/javascript">
var $selectedTourney = {{ $tourneyNo }}; // set $selectedTourney = the last $tourneyNo --let's say it is 209
</script>
{{ end }}
And here is how i would like to use it :
{{ with index . $selectedTourney}} // $selectedTourney should be replaced in the code by 209, as set before
{{.Name }}
{{ end }}
The second part of the code is not working ; i want to get the element from . having the index defined previously in the $selectedTourney variable.
The goal intended is that a list of tourneys is displayed, the user clicks on one of theses tourneys and the info about this tourney is displayed, using js, down on the same page.
Thanks a lot for the help :D