salix/examples/replybot/main.go

36 lines
534 B
Go
Raw Permalink Normal View History

2023-10-29 01:10:17 +00:00
package main
import (
_ "embed"
"log"
"os"
"go.elara.ws/salix"
)
//go:embed replybot.salix.txt
var tmpl string
var matches = [][]string{
{"https://i.imgur.com/aaaaaaa.jpg", "aaaaaaa.jpg"},
{"https://imgur.com/a/bbbbbbb.jpg", "a/bbbbbbb.jpg"},
}
func main() {
vars := map[string]any{
"type": "post",
"matches": matches,
}
t, err := salix.New().
ParseString("replybot.salix.txt", tmpl)
if err != nil {
log.Fatalln(err)
}
err = t.WithVarMap(vars).Execute(os.Stdout)
2023-10-29 01:10:17 +00:00
if err != nil {
log.Fatalln(err)
}
}