List tx templates on homepage
This commit is contained in:
4
main.go
4
main.go
@@ -22,7 +22,7 @@ type TxData struct {
|
|||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
var err error
|
var err error
|
||||||
tpl, err = template.ParseGlob("templates/*.txt")
|
tpl, err = template.ParseGlob("templates/*")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
@@ -33,7 +33,7 @@ func main() {
|
|||||||
fmt.Println("Hi")
|
fmt.Println("Hi")
|
||||||
|
|
||||||
http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
|
http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
|
||||||
http.ServeFile(w, r, "index.html")
|
tpl.ExecuteTemplate(w, "index.html", tpl)
|
||||||
})
|
})
|
||||||
|
|
||||||
http.HandleFunc("/action", func(w http.ResponseWriter, r *http.Request) {
|
http.HandleFunc("/action", func(w http.ResponseWriter, r *http.Request) {
|
||||||
|
|||||||
@@ -6,7 +6,13 @@
|
|||||||
<body>
|
<body>
|
||||||
<h1>Ledger Quick Note</h1>
|
<h1>Ledger Quick Note</h1>
|
||||||
<form action="/action" method="POST">
|
<form action="/action" method="POST">
|
||||||
<label>Action: <input name="action" type="text"></label>
|
<label>Action: <select name="action">
|
||||||
|
{{ range .Templates }}
|
||||||
|
{{ if ne .Name "index.html" }}
|
||||||
|
<option value="{{ .Name }}">{{ .Name }}</option>
|
||||||
|
{{ end }}
|
||||||
|
{{ end }}
|
||||||
|
</select></label>
|
||||||
<label>Amount: <input name="amount" type="number"></label>
|
<label>Amount: <input name="amount" type="number"></label>
|
||||||
<input type="submit">
|
<input type="submit">
|
||||||
</form>
|
</form>
|
||||||
Reference in New Issue
Block a user