From 62ae7789de2d9f4efa39dfbf39aea8f6eda8952a Mon Sep 17 00:00:00 2001 From: yanweidonog Date: Mon, 2 Mar 2026 11:46:44 +0800 Subject: [PATCH] fix --- cmd/lab/main.go | 18 ++++++++++++++ go.mod | 1 + go.sum | 2 ++ templates/hello.templ | 5 ++++ templates/hello_templ.go | 53 ++++++++++++++++++++++++++++++++++++++++ 5 files changed, 79 insertions(+) create mode 100644 cmd/lab/main.go create mode 100644 templates/hello.templ create mode 100644 templates/hello_templ.go diff --git a/cmd/lab/main.go b/cmd/lab/main.go new file mode 100644 index 0000000..cc0bd27 --- /dev/null +++ b/cmd/lab/main.go @@ -0,0 +1,18 @@ +package main + +import ( + "fmt" + "net/http" + + "git.apinb.com/senlinai/cloud/templates" + "github.com/a-h/templ" +) + +func main() { + component := templates.Hello("Tim") + + http.Handle("/", templ.Handler(component)) + + fmt.Println("Listening on :3000") + http.ListenAndServe(":3000", nil) +} diff --git a/go.mod b/go.mod index 47c4b2a..04b5f00 100644 --- a/go.mod +++ b/go.mod @@ -4,6 +4,7 @@ go 1.26.0 require ( git.apinb.com/bsm-sdk/core v0.1.9 + github.com/a-h/templ v0.3.1001 github.com/gin-gonic/gin v1.12.0 ) diff --git a/go.sum b/go.sum index e29bb9e..3fd9b05 100644 --- a/go.sum +++ b/go.sum @@ -1,5 +1,7 @@ git.apinb.com/bsm-sdk/core v0.1.9 h1:Pp0zpSeX7OnFb3JQdXdJHR74EvU02HnMauk4wI0/gVg= git.apinb.com/bsm-sdk/core v0.1.9/go.mod h1:R5Rm/Ep4D3mJ97dL6sLRi3jtfQxi2ftekp2E3frts/8= +github.com/a-h/templ v0.3.1001 h1:yHDTgexACdJttyiyamcTHXr2QkIeVF1MukLy44EAhMY= +github.com/a-h/templ v0.3.1001/go.mod h1:oCZcnKRf5jjsGpf2yELzQfodLphd2mwecwG4Crk5HBo= github.com/bsm/ginkgo/v2 v2.12.0 h1:Ny8MWAHyOepLGlLKYmXG4IEkioBysk6GpaRTLC8zwWs= github.com/bsm/ginkgo/v2 v2.12.0/go.mod h1:SwYbGRRDovPVboqFv0tPTcG1sN61LM1Z4ARdbAV9g4c= github.com/bsm/gomega v1.27.10 h1:yeMWxP2pV2fG3FgAODIY8EiRE3dy0aeFYt4l7wh6yKA= diff --git a/templates/hello.templ b/templates/hello.templ new file mode 100644 index 0000000..bf38b78 --- /dev/null +++ b/templates/hello.templ @@ -0,0 +1,5 @@ +package templates + +templ Hello(name string) { +
Hello, { name }
+} \ No newline at end of file diff --git a/templates/hello_templ.go b/templates/hello_templ.go new file mode 100644 index 0000000..6fe7dac --- /dev/null +++ b/templates/hello_templ.go @@ -0,0 +1,53 @@ +// Code generated by templ - DO NOT EDIT. + +// templ: version: v0.3.1001 +package templates + +//lint:file-ignore SA4006 This context is only used if a nested component is present. + +import "github.com/a-h/templ" +import templruntime "github.com/a-h/templ/runtime" + +func Hello(name string) templ.Component { + return templruntime.GeneratedTemplate(func(templ_7745c5c3_Input templruntime.GeneratedComponentInput) (templ_7745c5c3_Err error) { + templ_7745c5c3_W, ctx := templ_7745c5c3_Input.Writer, templ_7745c5c3_Input.Context + if templ_7745c5c3_CtxErr := ctx.Err(); templ_7745c5c3_CtxErr != nil { + return templ_7745c5c3_CtxErr + } + templ_7745c5c3_Buffer, templ_7745c5c3_IsBuffer := templruntime.GetBuffer(templ_7745c5c3_W) + if !templ_7745c5c3_IsBuffer { + defer func() { + templ_7745c5c3_BufErr := templruntime.ReleaseBuffer(templ_7745c5c3_Buffer) + if templ_7745c5c3_Err == nil { + templ_7745c5c3_Err = templ_7745c5c3_BufErr + } + }() + } + ctx = templ.InitializeContext(ctx) + templ_7745c5c3_Var1 := templ.GetChildren(ctx) + if templ_7745c5c3_Var1 == nil { + templ_7745c5c3_Var1 = templ.NopComponent + } + ctx = templ.ClearChildren(ctx) + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 1, "
Hello, ") + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + var templ_7745c5c3_Var2 string + templ_7745c5c3_Var2, templ_7745c5c3_Err = templ.JoinStringErrs(name) + if templ_7745c5c3_Err != nil { + return templ.Error{Err: templ_7745c5c3_Err, FileName: `hello.templ`, Line: 4, Col: 19} + } + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var2)) + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 2, "
") + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + return nil + }) +} + +var _ = templruntime.GeneratedTemplate