Arreglar etiquetas "form"
Estas etiquetas no soportan "omitempty"
This commit is contained in:
parent
78f3e96aa6
commit
db76fd1d3a
8
main.go
8
main.go
|
@ -47,7 +47,13 @@ func (renderer *TemplateRenderer) Render(w io.Writer, name string, data interfac
|
|||
func (template Template) TemplateController(c echo.Context) (err error) {
|
||||
entries, err := list.GetEntries()
|
||||
if err == nil {
|
||||
err = c.Render(http.StatusOK, string(template), entries)
|
||||
err = c.Render(http.StatusOK, string(template), struct {
|
||||
Entries []*storage.Entry
|
||||
Today storage.JSTime
|
||||
}{
|
||||
Entries: entries,
|
||||
Today: storage.JSTime(time.Now()),
|
||||
})
|
||||
}
|
||||
return
|
||||
}
|
||||
|
|
|
@ -5,11 +5,11 @@ import "fmt"
|
|||
type (
|
||||
Entry struct {
|
||||
Artist string `json:"artist" form:"artist"`
|
||||
Linkto string `json:"linkto" form:"linkto,omitempty"`
|
||||
Track string `json:"track" form:"track,omitempty"`
|
||||
Album string `json:"album" form:"album,omitempty"`
|
||||
Cover string `json:"cover" form:"cover,omitempty"`
|
||||
Date JSTime `json:"date" form:"date,omitempty"`
|
||||
Linkto string `json:"linkto" form:"linkto"`
|
||||
Track string `json:"track" form:"track"`
|
||||
Album string `json:"album" form:"album"`
|
||||
Cover string `json:"cover" form:"cover"`
|
||||
Date JSTime `json:"date" form:"date"`
|
||||
}
|
||||
)
|
||||
|
||||
|
|
|
@ -21,7 +21,7 @@
|
|||
<div class="form-elem"> <input name="track" type="text" placeholder="Canción"/> </div>
|
||||
<div class="form-elem"> <input name="album" type="text" placeholder="Álbum"/> </div>
|
||||
<div class="form-elem"> <input name="linkto" type="text" placeholder="Enlace"/> </div>
|
||||
<div class="form-elem"> <input name="date" type="date" placeholder="Fecha"/> </div>
|
||||
<div class="form-elem"> <input name="date" type="date" placeholder="Fecha" value="{{ .Today.String }}"/> </div>
|
||||
<hr/>
|
||||
<input type="submit" value="Añadir">
|
||||
</form>
|
||||
|
@ -35,7 +35,7 @@
|
|||
</button>
|
||||
<div class="action">
|
||||
<div class="scroll">
|
||||
{{ range $index, $elem := . }}
|
||||
{{ range $index, $elem := .Entries }}
|
||||
<a href="del/{{ $index }}" class="data-elem">
|
||||
{{ $elem.Showname }}
|
||||
</a>
|
||||
|
|
|
@ -147,7 +147,7 @@ nav > a:hover {
|
|||
<a href="admin/">Zona del admin <span class="emoji">😎</span></a>
|
||||
</nav>
|
||||
<main>
|
||||
{{ range . }}
|
||||
{{ range .Entries }}
|
||||
<a href="{{ .Linkto }}">
|
||||
<div class="elem">
|
||||
<img src="{{ .Cover }}" class="cover" loading="lazy">
|
||||
|
|
Loading…
Reference in New Issue