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