Hello, I’m trying to create quizzes on Hugo.
For the moment I have chosen to use /data
/quiz
My json looks like this :
{"query":
[
{"legend":"My query",
"labels": [{
"Ok":1,
"Not Ok":10,
"Dunno":100
}]
},
{"legend":"My 2nd query.",
"labels": [{
"Ok":1,
"Not Ok":10,
"Dunno":100
}]
}
]
}
Note I added an int
to the labels for the calculation of the result in JS later.
My template :
{{ define "main" }}
<div class="wrapper">
<h1>{{ .Title }}</h1>
{{ $urlJson := index .Site.Data.quiz .Params.urlJson }}
<form action="">
{{ range $i, $e := $urlJson}}
{{ range $a, $b := $e }}
<fieldset>
<legend>{{.legend }}</legend>
{{range $c, $d := .labels }}
<label>{{ $d }}</label>
{{end}}
</fieldset>
{{ end }}
{{ end }}
</form>
</div>
{{ end }}
I can get the right exit on the
But I only display the map for
My output :
<form action="">
<fieldset>
<legend>My query</legend>
<label>map[Dunno:100 Not Ok:10 Ok:1]</label>
</fieldset>
<fieldset>
<legend>My 2nd query.</legend>
<label>map[Dunno:100 Not Ok:10 Ok:1]</label>
</fieldset>
</form>
What do I miss about it?
I can modify my json if you think we can simplify it
Thanks,