shorgru/pkg/tpl/quote_admin.templ

37 lines
808 B
Text
Raw Permalink Normal View History

2024-10-06 17:04:37 +03:00
package tpl
import (
"sh.org.ru/pkg/model"
"strconv"
)
templ Admin(quotes []model.Quote, count int) {
@Layout(HeaderParams{}) {
for _, q := range quotes {
@QuoteAdmin(&q)
}
Всего { strconv.Itoa(count) } цитат.
}
}
templ QuoteAdmin(quote *model.Quote) {
<article>
<header>#{ strconv.Itoa(int(quote.ID)) }</header>
@templ.Raw(quote.Text())
<footer>
<form method="post" action="/admin/action">
<input type="hidden" name="id" value={ strconv.Itoa(int(quote.ID)) }/>
<div role="group">
<input class="primary" type="submit" name="action" value="approve"/>
<input class="secondary" type="submit" name="action" value="decline"/>
</div>
</form>
</footer>
</article>
}
type AdminForm struct {
ID int `form:"id"`
Action string `form:"action"`
}