Html ora dinamico

This commit is contained in:
Claudio Maggioni 2017-05-26 16:28:38 +02:00
parent 2d6a0b72a6
commit 51cbe818b4
2 changed files with 24 additions and 13 deletions

View file

@ -16,5 +16,9 @@ func handlerRoot(w http.ResponseWriter, r *http.Request) {
if err != nil {
panic(err.Error())
}
templ.Execute(w, new(interface{}))
varmap := map[string]interface{}{
"matrice": Matrix,
"tempoAggiorna": Clock,
}
templ.Execute(w, varmap)
}

View file

@ -1,6 +1,7 @@
<html>
<head>
<title>GoBug</title>
<meta http-equiv="refresh" content="{{ .tempoAggiorna }}">
<meta charset="UTF-8">
<style type="text/css">
h1,h2,h3,h4,p {
@ -39,18 +40,24 @@
</style>
</head>
<body>
<h1> Go bug</h1>
<table>
<tr>
<td class="cibo"></th>
<td class="razza1"></td>
<td class="razza2"></td>
</tr>
<tr>
<td></td>
<td></td>
<td></td>
</tr>
<h1>Go bug</h1>
<table>
{{range $riga := .matrice}}
<tr>
{{range $cella := $riga}}
<td {{ if not $cella }}
class="vuoto"
{{ else }}
{{ if $cella.IsFood }}
class="razza1"
{{ else }}
class="razza2"
{{ end }}
{{ end }}
>{{ $cella }}</td>
{{ end }}
</tr>
{{ end }}
</table>
</body>
</html>