refactor: simplify Datastar configuration API

Flatten DatastarConfig struct into Options (DatastarContent, DatastarPath)
and replace datastarHandlerRegistered bool with sync.Once for thread safety.
This commit is contained in:
Ryan Hamamura
2026-01-14 02:01:18 -10:00
parent ea7b9ad4a1
commit d4b831492e
3 changed files with 23 additions and 38 deletions

View File

@@ -45,9 +45,7 @@ func TestCustomDatastarContent(t *testing.T) {
customScript := []byte("// Custom Datastar Script")
v := New()
v.Config(Options{
Datastar: &DatastarConfig{
Content: customScript,
},
DatastarContent: customScript,
})
v.Page("/", func(c *Context) {
c.View(func() h.H { return h.Div() })
@@ -65,9 +63,7 @@ func TestCustomDatastarContent(t *testing.T) {
func TestCustomDatastarPath(t *testing.T) {
v := New()
v.Config(Options{
Datastar: &DatastarConfig{
Path: "/assets/datastar.js",
},
DatastarPath: "/assets/datastar.js",
})
v.Page("/test", func(c *Context) {
c.View(func() h.H { return h.Div() })