feat: 🎉 nace gorender

This commit is contained in:
2024-08-21 22:39:00 +02:00
commit 58033d8e37
13 changed files with 744 additions and 0 deletions
+37
View File
@@ -0,0 +1,37 @@
package main
import (
"fmt"
"net/http"
"text/template"
"github.com/zepyrshut/gorender"
)
func dummyFunc() string {
return "dummy function"
}
func main() {
newFuncs := template.FuncMap{
"dummyFunc": dummyFunc,
}
renderOpts := &gorender.Render{
EnableCache: true,
TemplatesPath: "template",
PageTemplatesPath: "template/pages",
Functions: newFuncs,
}
ren := gorender.New(gorender.WithRenderOptions(renderOpts))
http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
td := &gorender.TemplateData{}
ren.Template(w, r, "page.html", td)
})
fmt.Println("Server running on port 8080")
http.ListenAndServe(":8080", nil)
}