diff --git a/docs/docs/04-core-concepts/03-testing.md b/docs/docs/04-core-concepts/03-testing.md index 498e9cc2f..1e59cd0cf 100644 --- a/docs/docs/04-core-concepts/03-testing.md +++ b/docs/docs/04-core-concepts/03-testing.md @@ -181,6 +181,113 @@ func TestPostsHandler(t *testing.T) { } ``` +### Testing template arguments from a handler + +When an HTTP handler queries a database and renders a templ component with the result, it is useful to verify that the handler is passing the right data to the template — without having to parse the rendered HTML. + +templ's generated code supports an opt-in mechanism: if the request context contains a `map[string]any` value under the key `"_templ_args_map"`, the generated code populates it with the arguments passed to the component. This lets you inspect them directly in your test. + +The complete runnable example is at https://github.com/a-h/templ/blob/main/examples/testing-args/. + +Consider this handler that loads a user and renders a page: + +```go +// template.templ +templ userPage(u User) { +

{ u.Name }

+} +``` + +```go +// handler.go +type User struct { + ID int + Name string +} + +var getUser = func(id int) (User, error) { + return User{}, errors.New("user not found") +} + +func UserPage(w http.ResponseWriter, r *http.Request) { + id, _ := strconv.Atoi(r.PathValue("id")) + user, err := getUser(id) + if err != nil { + http.Error(w, "not found", http.StatusNotFound) + return + } + userPage(user).Render(r.Context(), w) +} + +func main() { + mux := http.NewServeMux() + mux.HandleFunc("GET /users/{id}", UserPage) + http.ListenAndServe(":8080", mux) +} +``` + +In the test, replace the `getUser` dependency, inject the args capture map into the context, call the mux, and read the captured arguments: + +```go +// handler_test.go +func TestUserHandlerPassesCorrectUser(t *testing.T) { + getUser = func(id int) (User, error) { + return User{ID: id, Name: "Alice"}, nil + } + + argsMap := make(map[string]any) + ctx := context.WithValue(context.Background(), "_templ_args_map", argsMap) + + mux := http.NewServeMux() + mux.HandleFunc("GET /users/{id}", UserPage) + + w := httptest.NewRecorder() + r := httptest.NewRequest(http.MethodGet, "/users/42", nil).WithContext(ctx) + + mux.ServeHTTP(w, r) + + u, ok := argsMap["u"].(User) + if !ok { + t.Fatal("template was not called or argument u was not captured") + } + if u.Name != "Alice" { + t.Errorf("expected user name Alice, got %q", u.Name) + } +} +``` + +The map key matches the **parameter name** in the templ function signature (`u` in `templ userPage(u User)`). For method receivers — `templ (this MyModel) Render(id int)` — the receiver variable is captured too, under its own name (`"this"`). + +#### Nested components and duplicate parameter names + +When components are nested, each one writes its arguments into the same map. If an outer and an inner component both have a parameter with the same name, **the outer component's value is kept** and the inner one is ignored. + +```go +templ layout(title string) { + + { title } + @page(title) // page also has a "title" parameter + +} + +templ page(title string) { +

{ title }

+} +``` + +```go +argsMap := make(map[string]any) +ctx := context.WithValue(context.Background(), "_templ_args_map", argsMap) + +layout("Outer title").Render(ctx, io.Discard) + +// argsMap["title"] == "Outer title" ← layout wins; page's value is discarded +``` + +This is intentional: in a handler test you typically call the top-level component directly, so the outermost arguments are the ones you want to inspect. + +This is not a test of the template output. It is a test of the **handler's logic**: confirming that it queries the right data and forwards it to the template unchanged. + ### Summary - goquery can be used effectively with templ for writing component level tests. diff --git a/examples/testing-args/go.mod b/examples/testing-args/go.mod new file mode 100644 index 000000000..ff408c49f --- /dev/null +++ b/examples/testing-args/go.mod @@ -0,0 +1,7 @@ +module github.com/a-h/templ/examples/testing-args + +go 1.25.0 + +replace github.com/a-h/templ => ../../ + +require github.com/a-h/templ v0.0.0-00010101000000-000000000000 diff --git a/examples/testing-args/go.sum b/examples/testing-args/go.sum new file mode 100644 index 000000000..5a8d551d8 --- /dev/null +++ b/examples/testing-args/go.sum @@ -0,0 +1,2 @@ +github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI= +github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= diff --git a/examples/testing-args/handler.go b/examples/testing-args/handler.go new file mode 100644 index 000000000..9ae3eaebc --- /dev/null +++ b/examples/testing-args/handler.go @@ -0,0 +1,32 @@ +package main + +import ( + "errors" + "net/http" + "strconv" +) + +type User struct { + ID int + Name string +} + +var getUser = func(id int) (User, error) { + return User{}, errors.New("user not found") +} + +func UserPage(w http.ResponseWriter, r *http.Request) { + id, _ := strconv.Atoi(r.PathValue("id")) + user, err := getUser(id) + if err != nil { + http.Error(w, "not found", http.StatusNotFound) + return + } + userPage(user).Render(r.Context(), w) +} + +func main() { + mux := http.NewServeMux() + mux.HandleFunc("GET /users/{id}", UserPage) + http.ListenAndServe(":8080", mux) +} diff --git a/examples/testing-args/handler_test.go b/examples/testing-args/handler_test.go new file mode 100644 index 000000000..fcc6ba78a --- /dev/null +++ b/examples/testing-args/handler_test.go @@ -0,0 +1,33 @@ +package main + +import ( + "context" + "net/http" + "net/http/httptest" + "testing" +) + +func TestUserHandlerPassesCorrectUser(t *testing.T) { + getUser = func(id int) (User, error) { + return User{ID: id, Name: "Alice"}, nil + } + + argsMap := make(map[string]any) + ctx := context.WithValue(context.Background(), "_templ_args_map", argsMap) + + mux := http.NewServeMux() + mux.HandleFunc("GET /users/{id}", UserPage) + + w := httptest.NewRecorder() + r := httptest.NewRequest(http.MethodGet, "/users/42", nil).WithContext(ctx) + + mux.ServeHTTP(w, r) + + u, ok := argsMap["u"].(User) + if !ok { + t.Fatal("template was not called or argument u was not captured") + } + if u.Name != "Alice" { + t.Errorf("expected user name Alice, got %q", u.Name) + } +} diff --git a/examples/testing-args/template.templ b/examples/testing-args/template.templ new file mode 100644 index 000000000..17ba0d287 --- /dev/null +++ b/examples/testing-args/template.templ @@ -0,0 +1,5 @@ +package main + +templ userPage(u User) { +

{ u.Name }

+} diff --git a/examples/testing-args/template_templ.go b/examples/testing-args/template_templ.go new file mode 100644 index 000000000..083c4119b --- /dev/null +++ b/examples/testing-args/template_templ.go @@ -0,0 +1,57 @@ +// Code generated by templ - DO NOT EDIT. + +// templ: version: v0.3.1036 +package main + +//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 userPage(u User) 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 + templ_7745c5c3_ArgsMap, templ_7745c5c3_ArgsOk := ctx.Value("_templ_args_map").(map[string]any) + if templ_7745c5c3_ArgsMap != nil && templ_7745c5c3_ArgsOk { + templruntime.SetTemplArg(templ_7745c5c3_ArgsMap, "u", u) + } + 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, "

") + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + var templ_7745c5c3_Var2 string + templ_7745c5c3_Var2, templ_7745c5c3_Err = templ.JoinStringErrs(u.Name) + if templ_7745c5c3_Err != nil { + return templ.Error{Err: templ_7745c5c3_Err, FileName: `examples/testing-args/template.templ`, Line: 4, Col: 13} + } + _, 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 diff --git a/examples/testing-args/testing-args b/examples/testing-args/testing-args new file mode 100755 index 000000000..d4f889c99 Binary files /dev/null and b/examples/testing-args/testing-args differ diff --git a/generator/generator.go b/generator/generator.go index b3e080529..052c78445 100644 --- a/generator/generator.go +++ b/generator/generator.go @@ -477,6 +477,29 @@ func (g *generator) writeTemplate(nodeIdx int, t *parser.HTMLTemplate) error { if _, err = g.w.WriteIndent(indentLevel, "templ_7745c5c3_W, ctx := templ_7745c5c3_Input.Writer, templ_7745c5c3_Input.Context\n"); err != nil { return err } + var allNames []string + if recv := extractReceiverName(t.Expression.Value); recv != "" { + allNames = append(allNames, recv) + } + allNames = append(allNames, extractParamNames(extractParamList(t.Expression.Value))...) + if len(allNames) > 0 { + if _, err = g.w.WriteIndent(indentLevel, "templ_7745c5c3_ArgsMap, templ_7745c5c3_ArgsOk := ctx.Value(\"_templ_args_map\").(map[string]any)\n"); err != nil { + return err + } + if _, err = g.w.WriteIndent(indentLevel, "if templ_7745c5c3_ArgsMap != nil && templ_7745c5c3_ArgsOk {\n"); err != nil { + return err + } + indentLevel++ + for _, name := range allNames { + if _, err = g.w.WriteIndent(indentLevel, fmt.Sprintf("templruntime.SetTemplArg(templ_7745c5c3_ArgsMap, %q, %s)\n", name, name)); err != nil { + return err + } + } + indentLevel-- + if _, err = g.w.WriteIndent(indentLevel, "}\n"); err != nil { + return err + } + } if _, err = g.w.WriteIndent(indentLevel, "if templ_7745c5c3_CtxErr := ctx.Err(); templ_7745c5c3_CtxErr != nil {\n"); err != nil { return err } @@ -1839,6 +1862,88 @@ func functionName(name string, body string) string { return "__templ_" + name + "_" + hp } +func extractReceiverName(expression string) string { + trimmed := strings.TrimSpace(expression) + if !strings.HasPrefix(trimmed, "(") { + return "" + } + depth := 0 + for i, ch := range trimmed { + switch ch { + case '(': + depth++ + case ')': + depth-- + if depth == 0 { + parts := strings.Fields(strings.TrimSpace(trimmed[1:i])) + if len(parts) >= 1 { + return parts[0] + } + return "" + } + } + } + return "" +} + +func extractParamList(expression string) string { + lastClose := strings.LastIndex(expression, ")") + if lastClose == -1 { + return "" + } + depth := 0 + for i := lastClose; i >= 0; i-- { + if expression[i] == ')' { + depth++ + } else if expression[i] == '(' { + depth-- + if depth == 0 { + return expression[i+1 : lastClose] + } + } + } + return "" +} + +func extractParamNames(paramList string) []string { + if strings.TrimSpace(paramList) == "" { + return nil + } + var params []string + var current strings.Builder + depth := 0 + for _, ch := range paramList { + switch ch { + case '(', '[', '{': + depth++ + current.WriteRune(ch) + case ')', ']', '}': + depth-- + current.WriteRune(ch) + case ',': + if depth == 0 { + params = append(params, strings.TrimSpace(current.String())) + current.Reset() + } else { + current.WriteRune(ch) + } + default: + current.WriteRune(ch) + } + } + if s := strings.TrimSpace(current.String()); s != "" { + params = append(params, s) + } + var names []string + for _, param := range params { + parts := strings.Fields(param) + if len(parts) >= 1 { + names = append(names, strings.TrimPrefix(parts[0], "...")) + } + } + return names +} + func stripTypes(parameters string) string { variableNames := []string{} params := strings.Split(parameters, ",") diff --git a/generator/test-a-href/template_templ.go b/generator/test-a-href/template_templ.go index 244b19639..aad297fbc 100644 --- a/generator/test-a-href/template_templ.go +++ b/generator/test-a-href/template_templ.go @@ -1,5 +1,6 @@ // Code generated by templ - DO NOT EDIT. +// templ: version: v0.3.1036 package testahref //lint:file-ignore SA4006 This context is only used if a nested component is present. diff --git a/generator/test-args-map/args_test.go b/generator/test-args-map/args_test.go new file mode 100644 index 000000000..1a134fc6f --- /dev/null +++ b/generator/test-args-map/args_test.go @@ -0,0 +1,42 @@ +package testargsmap + +import ( + "context" + "io" + "testing" +) + +// TestArgsMap documents and verifies the testability pattern for templ components. +// +// Usage in a handler test: +// 1. Create the map and inject it into the context with the key "_templ_args_map" +// 2. Execute the handler/component with that context +// 3. Read the arguments from the map using the parameter name as the key +func TestArgsMap(t *testing.T) { + argsMap := make(map[string]any) + ctx := context.WithValue(context.Background(), "_templ_args_map", argsMap) + + if err := greeting("Alice", 42).Render(ctx, io.Discard); err != nil { + t.Fatal(err) + } + + if got, ok := argsMap["name"].(string); !ok || got != "Alice" { + t.Errorf("name: want Alice, got %v", argsMap["name"]) + } + if got, ok := argsMap["count"].(int); !ok || got != 42 { + t.Errorf("count: want 42, got %v", argsMap["count"]) + } +} + +func TestArgsMapNotInjectedWithoutContextKey(t *testing.T) { + argsMap := make(map[string]any) + ctx := context.Background() // no "_templ_args_map" key + + if err := greeting("Bob", 7).Render(ctx, io.Discard); err != nil { + t.Fatal(err) + } + + if len(argsMap) != 0 { + t.Errorf("expected empty map, got %v", argsMap) + } +} diff --git a/generator/test-args-map/template.templ b/generator/test-args-map/template.templ new file mode 100644 index 000000000..399d7d82f --- /dev/null +++ b/generator/test-args-map/template.templ @@ -0,0 +1,5 @@ +package testargsmap + +templ greeting(name string, count int) { +

Hello, { name }! You have { count } messages.

+} diff --git a/generator/test-args-map/template_templ.go b/generator/test-args-map/template_templ.go new file mode 100644 index 000000000..1bbcc8c76 --- /dev/null +++ b/generator/test-args-map/template_templ.go @@ -0,0 +1,71 @@ +// Code generated by templ - DO NOT EDIT. + +// templ: version: v0.3.1036 +package testargsmap + +//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 greeting(name string, count int) 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 + templ_7745c5c3_ArgsMap, templ_7745c5c3_ArgsOk := ctx.Value("_templ_args_map").(map[string]any) + if templ_7745c5c3_ArgsMap != nil && templ_7745c5c3_ArgsOk { + templruntime.SetTemplArg(templ_7745c5c3_ArgsMap, "name", name) + templruntime.SetTemplArg(templ_7745c5c3_ArgsMap, "count", count) + } + 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: `generator/test-args-map/template.templ`, Line: 4, Col: 17} + } + _, 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, "! You have ") + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + var templ_7745c5c3_Var3 string + templ_7745c5c3_Var3, templ_7745c5c3_Err = templ.JoinStringErrs(count) + if templ_7745c5c3_Err != nil { + return templ.Error{Err: templ_7745c5c3_Err, FileName: `generator/test-args-map/template.templ`, Line: 4, Col: 37} + } + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var3)) + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 3, " messages.

") + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + return nil + }) +} + +var _ = templruntime.GeneratedTemplate diff --git a/generator/test-attribute-comments/template_templ.go b/generator/test-attribute-comments/template_templ.go index b37e3d452..5f8f27fb5 100644 --- a/generator/test-attribute-comments/template_templ.go +++ b/generator/test-attribute-comments/template_templ.go @@ -1,5 +1,6 @@ // Code generated by templ - DO NOT EDIT. +// templ: version: v0.3.1036 package testattributecomments //lint:file-ignore SA4006 This context is only used if a nested component is present. diff --git a/generator/test-attribute-errors/template_templ.go b/generator/test-attribute-errors/template_templ.go index cc2da7a1b..512578ad1 100644 --- a/generator/test-attribute-errors/template_templ.go +++ b/generator/test-attribute-errors/template_templ.go @@ -1,5 +1,6 @@ // Code generated by templ - DO NOT EDIT. +// templ: version: v0.3.1036 package testattrerrs //lint:file-ignore SA4006 This context is only used if a nested component is present. @@ -21,6 +22,10 @@ func funcWithError(in error) (s string, err error) { func TestComponent(err error) 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 + templ_7745c5c3_ArgsMap, templ_7745c5c3_ArgsOk := ctx.Value("_templ_args_map").(map[string]any) + if templ_7745c5c3_ArgsMap != nil && templ_7745c5c3_ArgsOk { + templruntime.SetTemplArg(templ_7745c5c3_ArgsMap, "err", err) + } if templ_7745c5c3_CtxErr := ctx.Err(); templ_7745c5c3_CtxErr != nil { return templ_7745c5c3_CtxErr } diff --git a/generator/test-attribute-escaping/template_templ.go b/generator/test-attribute-escaping/template_templ.go index 1996ac1fb..699cd0833 100644 --- a/generator/test-attribute-escaping/template_templ.go +++ b/generator/test-attribute-escaping/template_templ.go @@ -1,5 +1,6 @@ // Code generated by templ - DO NOT EDIT. +// templ: version: v0.3.1036 package testhtml //lint:file-ignore SA4006 This context is only used if a nested component is present. @@ -10,6 +11,10 @@ import templruntime "github.com/a-h/templ/runtime" func BasicTemplate(url 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 + templ_7745c5c3_ArgsMap, templ_7745c5c3_ArgsOk := ctx.Value("_templ_args_map").(map[string]any) + if templ_7745c5c3_ArgsMap != nil && templ_7745c5c3_ArgsOk { + templruntime.SetTemplArg(templ_7745c5c3_ArgsMap, "url", url) + } if templ_7745c5c3_CtxErr := ctx.Err(); templ_7745c5c3_CtxErr != nil { return templ_7745c5c3_CtxErr } diff --git a/generator/test-call/template_templ.go b/generator/test-call/template_templ.go index d54059892..5f8e940ef 100644 --- a/generator/test-call/template_templ.go +++ b/generator/test-call/template_templ.go @@ -1,5 +1,6 @@ // Code generated by templ - DO NOT EDIT. +// templ: version: v0.3.1036 package testcall //lint:file-ignore SA4006 This context is only used if a nested component is present. @@ -102,6 +103,10 @@ func a() templ.Component { func b(child templ.Component) 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 + templ_7745c5c3_ArgsMap, templ_7745c5c3_ArgsOk := ctx.Value("_templ_args_map").(map[string]any) + if templ_7745c5c3_ArgsMap != nil && templ_7745c5c3_ArgsOk { + templruntime.SetTemplArg(templ_7745c5c3_ArgsMap, "child", child) + } if templ_7745c5c3_CtxErr := ctx.Err(); templ_7745c5c3_CtxErr != nil { return templ_7745c5c3_CtxErr } @@ -135,6 +140,10 @@ func b(child templ.Component) templ.Component { func c(text 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 + templ_7745c5c3_ArgsMap, templ_7745c5c3_ArgsOk := ctx.Value("_templ_args_map").(map[string]any) + if templ_7745c5c3_ArgsMap != nil && templ_7745c5c3_ArgsOk { + templruntime.SetTemplArg(templ_7745c5c3_ArgsMap, "text", text) + } if templ_7745c5c3_CtxErr := ctx.Err(); templ_7745c5c3_CtxErr != nil { return templ_7745c5c3_CtxErr } @@ -235,6 +244,10 @@ func e() templ.Component { func showOne(component templ.Component) 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 + templ_7745c5c3_ArgsMap, templ_7745c5c3_ArgsOk := ctx.Value("_templ_args_map").(map[string]any) + if templ_7745c5c3_ArgsMap != nil && templ_7745c5c3_ArgsOk { + templruntime.SetTemplArg(templ_7745c5c3_ArgsMap, "component", component) + } if templ_7745c5c3_CtxErr := ctx.Err(); templ_7745c5c3_CtxErr != nil { return templ_7745c5c3_CtxErr } diff --git a/generator/test-cancelled-context/template_templ.go b/generator/test-cancelled-context/template_templ.go index aafab1856..cf2dfece6 100644 --- a/generator/test-cancelled-context/template_templ.go +++ b/generator/test-cancelled-context/template_templ.go @@ -1,5 +1,6 @@ // Code generated by templ - DO NOT EDIT. +// templ: version: v0.3.1036 package testcancelledcontext //lint:file-ignore SA4006 This context is only used if a nested component is present. diff --git a/generator/test-class-whitespace/template_templ.go b/generator/test-class-whitespace/template_templ.go index 18af6ae89..91e2b95d1 100644 --- a/generator/test-class-whitespace/template_templ.go +++ b/generator/test-class-whitespace/template_templ.go @@ -1,5 +1,6 @@ // Code generated by templ - DO NOT EDIT. +// templ: version: v0.3.1036 package testclasswhitespace //lint:file-ignore SA4006 This context is only used if a nested component is present. diff --git a/generator/test-complex-attributes/template_templ.go b/generator/test-complex-attributes/template_templ.go index 533d526cd..c96ecf51d 100644 --- a/generator/test-complex-attributes/template_templ.go +++ b/generator/test-complex-attributes/template_templ.go @@ -1,5 +1,6 @@ // Code generated by templ - DO NOT EDIT. +// templ: version: v0.3.1036 package testcomplexattributes //lint:file-ignore SA4006 This context is only used if a nested component is present. diff --git a/generator/test-constant-attribute-escaping/template_templ.go b/generator/test-constant-attribute-escaping/template_templ.go index e1e1b2675..60b636eac 100644 --- a/generator/test-constant-attribute-escaping/template_templ.go +++ b/generator/test-constant-attribute-escaping/template_templ.go @@ -1,5 +1,6 @@ // Code generated by templ - DO NOT EDIT. +// templ: version: v0.3.1036 package testconstantattributeescaping //lint:file-ignore SA4006 This context is only used if a nested component is present. diff --git a/generator/test-context/template_templ.go b/generator/test-context/template_templ.go index 840c83298..def49a800 100644 --- a/generator/test-context/template_templ.go +++ b/generator/test-context/template_templ.go @@ -1,5 +1,6 @@ // Code generated by templ - DO NOT EDIT. +// templ: version: v0.3.1036 package testcontext //lint:file-ignore SA4006 This context is only used if a nested component is present. diff --git a/generator/test-css-expression/template_templ.go b/generator/test-css-expression/template_templ.go index d2899055a..508870822 100644 --- a/generator/test-css-expression/template_templ.go +++ b/generator/test-css-expression/template_templ.go @@ -1,5 +1,6 @@ // Code generated by templ - DO NOT EDIT. +// templ: version: v0.3.1036 package testcssexpression //lint:file-ignore SA4006 This context is only used if a nested component is present. diff --git a/generator/test-css-middleware/template_templ.go b/generator/test-css-middleware/template_templ.go index 9ede8e666..6b06b8c90 100644 --- a/generator/test-css-middleware/template_templ.go +++ b/generator/test-css-middleware/template_templ.go @@ -1,5 +1,6 @@ // Code generated by templ - DO NOT EDIT. +// templ: version: v0.3.1036 package testcssmiddleware //lint:file-ignore SA4006 This context is only used if a nested component is present. @@ -20,6 +21,10 @@ func red() templ.CSSClass { func render(s 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 + templ_7745c5c3_ArgsMap, templ_7745c5c3_ArgsOk := ctx.Value("_templ_args_map").(map[string]any) + if templ_7745c5c3_ArgsMap != nil && templ_7745c5c3_ArgsOk { + templruntime.SetTemplArg(templ_7745c5c3_ArgsMap, "s", s) + } if templ_7745c5c3_CtxErr := ctx.Err(); templ_7745c5c3_CtxErr != nil { return templ_7745c5c3_CtxErr } diff --git a/generator/test-css-usage/template_templ.go b/generator/test-css-usage/template_templ.go index 88452a4d9..a40693776 100644 --- a/generator/test-css-usage/template_templ.go +++ b/generator/test-css-usage/template_templ.go @@ -1,5 +1,6 @@ // Code generated by templ - DO NOT EDIT. +// templ: version: v0.3.1036 package testcssusage //lint:file-ignore SA4006 This context is only used if a nested component is present. @@ -478,6 +479,10 @@ func windVaneRotation(degrees float64) templ.CSSClass { func Rotate(degrees float64) 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 + templ_7745c5c3_ArgsMap, templ_7745c5c3_ArgsOk := ctx.Value("_templ_args_map").(map[string]any) + if templ_7745c5c3_ArgsMap != nil && templ_7745c5c3_ArgsOk { + templruntime.SetTemplArg(templ_7745c5c3_ArgsMap, "degrees", degrees) + } if templ_7745c5c3_CtxErr := ctx.Err(); templ_7745c5c3_CtxErr != nil { return templ_7745c5c3_CtxErr } diff --git a/generator/test-doctype-html4/template_templ.go b/generator/test-doctype-html4/template_templ.go index f098a29d0..cd762a51d 100644 --- a/generator/test-doctype-html4/template_templ.go +++ b/generator/test-doctype-html4/template_templ.go @@ -1,5 +1,6 @@ // Code generated by templ - DO NOT EDIT. +// templ: version: v0.3.1036 package testdoctype //lint:file-ignore SA4006 This context is only used if a nested component is present. @@ -10,6 +11,11 @@ import templruntime "github.com/a-h/templ/runtime" func Layout(title, content 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 + templ_7745c5c3_ArgsMap, templ_7745c5c3_ArgsOk := ctx.Value("_templ_args_map").(map[string]any) + if templ_7745c5c3_ArgsMap != nil && templ_7745c5c3_ArgsOk { + templruntime.SetTemplArg(templ_7745c5c3_ArgsMap, "title", title) + templruntime.SetTemplArg(templ_7745c5c3_ArgsMap, "content", content) + } if templ_7745c5c3_CtxErr := ctx.Err(); templ_7745c5c3_CtxErr != nil { return templ_7745c5c3_CtxErr } diff --git a/generator/test-doctype/template_templ.go b/generator/test-doctype/template_templ.go index 6da16edce..b692a4767 100644 --- a/generator/test-doctype/template_templ.go +++ b/generator/test-doctype/template_templ.go @@ -1,5 +1,6 @@ // Code generated by templ - DO NOT EDIT. +// templ: version: v0.3.1036 package testdoctype //lint:file-ignore SA4006 This context is only used if a nested component is present. @@ -10,6 +11,11 @@ import templruntime "github.com/a-h/templ/runtime" func Layout(title, content 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 + templ_7745c5c3_ArgsMap, templ_7745c5c3_ArgsOk := ctx.Value("_templ_args_map").(map[string]any) + if templ_7745c5c3_ArgsMap != nil && templ_7745c5c3_ArgsOk { + templruntime.SetTemplArg(templ_7745c5c3_ArgsMap, "title", title) + templruntime.SetTemplArg(templ_7745c5c3_ArgsMap, "content", content) + } if templ_7745c5c3_CtxErr := ctx.Err(); templ_7745c5c3_CtxErr != nil { return templ_7745c5c3_CtxErr } diff --git a/generator/test-element-attributes/template_templ.go b/generator/test-element-attributes/template_templ.go index 0b7563081..6cafbcf12 100644 --- a/generator/test-element-attributes/template_templ.go +++ b/generator/test-element-attributes/template_templ.go @@ -1,5 +1,6 @@ // Code generated by templ - DO NOT EDIT. +// templ: version: v0.3.1036 package testelementattributes //lint:file-ignore SA4006 This context is only used if a nested component is present. @@ -30,6 +31,10 @@ func unimportant() templ.CSSClass { func render(p person) 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 + templ_7745c5c3_ArgsMap, templ_7745c5c3_ArgsOk := ctx.Value("_templ_args_map").(map[string]any) + if templ_7745c5c3_ArgsMap != nil && templ_7745c5c3_ArgsOk { + templruntime.SetTemplArg(templ_7745c5c3_ArgsMap, "p", p) + } if templ_7745c5c3_CtxErr := ctx.Err(); templ_7745c5c3_CtxErr != nil { return templ_7745c5c3_CtxErr } diff --git a/generator/test-elseif/template_templ.go b/generator/test-elseif/template_templ.go index de3800681..7b7cfcf64 100644 --- a/generator/test-elseif/template_templ.go +++ b/generator/test-elseif/template_templ.go @@ -1,5 +1,6 @@ // Code generated by templ - DO NOT EDIT. +// templ: version: v0.3.1036 package elseif //lint:file-ignore SA4006 This context is only used if a nested component is present. @@ -10,6 +11,10 @@ import templruntime "github.com/a-h/templ/runtime" func render(d data) 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 + templ_7745c5c3_ArgsMap, templ_7745c5c3_ArgsOk := ctx.Value("_templ_args_map").(map[string]any) + if templ_7745c5c3_ArgsMap != nil && templ_7745c5c3_ArgsOk { + templruntime.SetTemplArg(templ_7745c5c3_ArgsMap, "d", d) + } if templ_7745c5c3_CtxErr := ctx.Err(); templ_7745c5c3_CtxErr != nil { return templ_7745c5c3_CtxErr } diff --git a/generator/test-for/template_templ.go b/generator/test-for/template_templ.go index 50b059a5f..92b7f365a 100644 --- a/generator/test-for/template_templ.go +++ b/generator/test-for/template_templ.go @@ -1,5 +1,6 @@ // Code generated by templ - DO NOT EDIT. +// templ: version: v0.3.1036 package testfor //lint:file-ignore SA4006 This context is only used if a nested component is present. @@ -10,6 +11,10 @@ import templruntime "github.com/a-h/templ/runtime" func render(items []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 + templ_7745c5c3_ArgsMap, templ_7745c5c3_ArgsOk := ctx.Value("_templ_args_map").(map[string]any) + if templ_7745c5c3_ArgsMap != nil && templ_7745c5c3_ArgsOk { + templruntime.SetTemplArg(templ_7745c5c3_ArgsMap, "items", items) + } if templ_7745c5c3_CtxErr := ctx.Err(); templ_7745c5c3_CtxErr != nil { return templ_7745c5c3_CtxErr } diff --git a/generator/test-form-action/template_templ.go b/generator/test-form-action/template_templ.go index 9d6141781..ced7e7b72 100644 --- a/generator/test-form-action/template_templ.go +++ b/generator/test-form-action/template_templ.go @@ -1,5 +1,6 @@ // Code generated by templ - DO NOT EDIT. +// templ: version: v0.3.1036 package testahref //lint:file-ignore SA4006 This context is only used if a nested component is present. diff --git a/generator/test-fragment/template_templ.go b/generator/test-fragment/template_templ.go index cf575eb40..4b1ee3f82 100644 --- a/generator/test-fragment/template_templ.go +++ b/generator/test-fragment/template_templ.go @@ -1,5 +1,6 @@ // Code generated by templ - DO NOT EDIT. +// templ: version: v0.3.1036 package testfragment //lint:file-ignore SA4006 This context is only used if a nested component is present. diff --git a/generator/test-go-comments/template_templ.go b/generator/test-go-comments/template_templ.go index ba66c7492..6c045ac10 100644 --- a/generator/test-go-comments/template_templ.go +++ b/generator/test-go-comments/template_templ.go @@ -1,5 +1,6 @@ // Code generated by templ - DO NOT EDIT. +// templ: version: v0.3.1036 package testcomment //lint:file-ignore SA4006 This context is only used if a nested component is present. @@ -10,6 +11,10 @@ import templruntime "github.com/a-h/templ/runtime" func render(content 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 + templ_7745c5c3_ArgsMap, templ_7745c5c3_ArgsOk := ctx.Value("_templ_args_map").(map[string]any) + if templ_7745c5c3_ArgsMap != nil && templ_7745c5c3_ArgsOk { + templruntime.SetTemplArg(templ_7745c5c3_ArgsMap, "content", content) + } if templ_7745c5c3_CtxErr := ctx.Err(); templ_7745c5c3_CtxErr != nil { return templ_7745c5c3_CtxErr } diff --git a/generator/test-go-template-in-templ/template_templ.go b/generator/test-go-template-in-templ/template_templ.go index 4e699b554..274a64bd0 100644 --- a/generator/test-go-template-in-templ/template_templ.go +++ b/generator/test-go-template-in-templ/template_templ.go @@ -1,5 +1,6 @@ // Code generated by templ - DO NOT EDIT. +// templ: version: v0.3.1036 package testgotemplates //lint:file-ignore SA4006 This context is only used if a nested component is present. diff --git a/generator/test-html-comment/template_templ.go b/generator/test-html-comment/template_templ.go index bf755633a..c1c130f62 100644 --- a/generator/test-html-comment/template_templ.go +++ b/generator/test-html-comment/template_templ.go @@ -1,5 +1,6 @@ // Code generated by templ - DO NOT EDIT. +// templ: version: v0.3.1036 package testcomment //lint:file-ignore SA4006 This context is only used if a nested component is present. @@ -10,6 +11,10 @@ import templruntime "github.com/a-h/templ/runtime" func render(content 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 + templ_7745c5c3_ArgsMap, templ_7745c5c3_ArgsOk := ctx.Value("_templ_args_map").(map[string]any) + if templ_7745c5c3_ArgsMap != nil && templ_7745c5c3_ArgsOk { + templruntime.SetTemplArg(templ_7745c5c3_ArgsMap, "content", content) + } if templ_7745c5c3_CtxErr := ctx.Err(); templ_7745c5c3_CtxErr != nil { return templ_7745c5c3_CtxErr } @@ -76,6 +81,10 @@ func render(content string) templ.Component { func paragraph(content 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 + templ_7745c5c3_ArgsMap, templ_7745c5c3_ArgsOk := ctx.Value("_templ_args_map").(map[string]any) + if templ_7745c5c3_ArgsMap != nil && templ_7745c5c3_ArgsOk { + templruntime.SetTemplArg(templ_7745c5c3_ArgsMap, "content", content) + } if templ_7745c5c3_CtxErr := ctx.Err(); templ_7745c5c3_CtxErr != nil { return templ_7745c5c3_CtxErr } diff --git a/generator/test-html/template_templ.go b/generator/test-html/template_templ.go index 74c96ace6..9207ab08d 100644 --- a/generator/test-html/template_templ.go +++ b/generator/test-html/template_templ.go @@ -1,5 +1,6 @@ // Code generated by templ - DO NOT EDIT. +// templ: version: v0.3.1036 package testhtml //lint:file-ignore SA4006 This context is only used if a nested component is present. @@ -10,6 +11,10 @@ import templruntime "github.com/a-h/templ/runtime" func render(p person) 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 + templ_7745c5c3_ArgsMap, templ_7745c5c3_ArgsOk := ctx.Value("_templ_args_map").(map[string]any) + if templ_7745c5c3_ArgsMap != nil && templ_7745c5c3_ArgsOk { + templruntime.SetTemplArg(templ_7745c5c3_ArgsMap, "p", p) + } if templ_7745c5c3_CtxErr := ctx.Err(); templ_7745c5c3_CtxErr != nil { return templ_7745c5c3_CtxErr } diff --git a/generator/test-if/template_templ.go b/generator/test-if/template_templ.go index 4efcaa6bc..90b489c9e 100644 --- a/generator/test-if/template_templ.go +++ b/generator/test-if/template_templ.go @@ -1,5 +1,6 @@ // Code generated by templ - DO NOT EDIT. +// templ: version: v0.3.1036 package testif //lint:file-ignore SA4006 This context is only used if a nested component is present. @@ -10,6 +11,10 @@ import templruntime "github.com/a-h/templ/runtime" func render(d data) 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 + templ_7745c5c3_ArgsMap, templ_7745c5c3_ArgsOk := ctx.Value("_templ_args_map").(map[string]any) + if templ_7745c5c3_ArgsMap != nil && templ_7745c5c3_ArgsOk { + templruntime.SetTemplArg(templ_7745c5c3_ArgsMap, "d", d) + } if templ_7745c5c3_CtxErr := ctx.Err(); templ_7745c5c3_CtxErr != nil { return templ_7745c5c3_CtxErr } diff --git a/generator/test-ifelse/template_templ.go b/generator/test-ifelse/template_templ.go index 8c791eacd..c5c6ec166 100644 --- a/generator/test-ifelse/template_templ.go +++ b/generator/test-ifelse/template_templ.go @@ -1,5 +1,6 @@ // Code generated by templ - DO NOT EDIT. +// templ: version: v0.3.1036 package ifelse //lint:file-ignore SA4006 This context is only used if a nested component is present. @@ -10,6 +11,10 @@ import templruntime "github.com/a-h/templ/runtime" func render(d data) 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 + templ_7745c5c3_ArgsMap, templ_7745c5c3_ArgsOk := ctx.Value("_templ_args_map").(map[string]any) + if templ_7745c5c3_ArgsMap != nil && templ_7745c5c3_ArgsOk { + templruntime.SetTemplArg(templ_7745c5c3_ArgsMap, "d", d) + } if templ_7745c5c3_CtxErr := ctx.Err(); templ_7745c5c3_CtxErr != nil { return templ_7745c5c3_CtxErr } diff --git a/generator/test-import/template_templ.go b/generator/test-import/template_templ.go index 6b224ed46..d3c2cce9f 100644 --- a/generator/test-import/template_templ.go +++ b/generator/test-import/template_templ.go @@ -1,5 +1,6 @@ // Code generated by templ - DO NOT EDIT. +// templ: version: v0.3.1036 package testimport //lint:file-ignore SA4006 This context is only used if a nested component is present. diff --git a/generator/test-js-unsafe-usage/template_templ.go b/generator/test-js-unsafe-usage/template_templ.go index 1c0cb1fe3..51f2e94c5 100644 --- a/generator/test-js-unsafe-usage/template_templ.go +++ b/generator/test-js-unsafe-usage/template_templ.go @@ -1,5 +1,6 @@ // Code generated by templ - DO NOT EDIT. +// templ: version: v0.3.1036 package testjsunsafeusage //lint:file-ignore SA4006 This context is only used if a nested component is present. diff --git a/generator/test-js-usage/template_templ.go b/generator/test-js-usage/template_templ.go index d1dee4082..fa0b743b1 100644 --- a/generator/test-js-usage/template_templ.go +++ b/generator/test-js-usage/template_templ.go @@ -1,5 +1,6 @@ // Code generated by templ - DO NOT EDIT. +// templ: version: v0.3.1036 package testjsusage //lint:file-ignore SA4006 This context is only used if a nested component is present. diff --git a/generator/test-method/template_templ.go b/generator/test-method/template_templ.go index 51ba91801..8a0ce65b0 100644 --- a/generator/test-method/template_templ.go +++ b/generator/test-method/template_templ.go @@ -1,5 +1,6 @@ // Code generated by templ - DO NOT EDIT. +// templ: version: v0.3.1036 package testmethod //lint:file-ignore SA4006 This context is only used if a nested component is present. @@ -14,6 +15,10 @@ type Data struct { func (d Data) Method() 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 + templ_7745c5c3_ArgsMap, templ_7745c5c3_ArgsOk := ctx.Value("_templ_args_map").(map[string]any) + if templ_7745c5c3_ArgsMap != nil && templ_7745c5c3_ArgsOk { + templruntime.SetTemplArg(templ_7745c5c3_ArgsMap, "d", d) + } if templ_7745c5c3_CtxErr := ctx.Err(); templ_7745c5c3_CtxErr != nil { return templ_7745c5c3_CtxErr } diff --git a/generator/test-once/template_templ.go b/generator/test-once/template_templ.go index 605d6520e..8fbf68ad8 100644 --- a/generator/test-once/template_templ.go +++ b/generator/test-once/template_templ.go @@ -1,5 +1,6 @@ // Code generated by templ - DO NOT EDIT. +// templ: version: v0.3.1036 package once //lint:file-ignore SA4006 This context is only used if a nested component is present. @@ -12,6 +13,11 @@ var helloHandle = templ.NewOnceHandle() func hello(label, 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 + templ_7745c5c3_ArgsMap, templ_7745c5c3_ArgsOk := ctx.Value("_templ_args_map").(map[string]any) + if templ_7745c5c3_ArgsMap != nil && templ_7745c5c3_ArgsOk { + templruntime.SetTemplArg(templ_7745c5c3_ArgsMap, "label", label) + templruntime.SetTemplArg(templ_7745c5c3_ArgsMap, "name", name) + } if templ_7745c5c3_CtxErr := ctx.Err(); templ_7745c5c3_CtxErr != nil { return templ_7745c5c3_CtxErr } diff --git a/generator/test-only-scripts/template_templ.go b/generator/test-only-scripts/template_templ.go index 96ae80c36..64570749c 100644 --- a/generator/test-only-scripts/template_templ.go +++ b/generator/test-only-scripts/template_templ.go @@ -1,5 +1,6 @@ // Code generated by templ - DO NOT EDIT. +// templ: version: v0.3.1036 package onlyscripts //lint:file-ignore SA4006 This context is only used if a nested component is present. diff --git a/generator/test-primitives/template_templ.go b/generator/test-primitives/template_templ.go index 06485e761..00d1e18de 100644 --- a/generator/test-primitives/template_templ.go +++ b/generator/test-primitives/template_templ.go @@ -1,5 +1,6 @@ // Code generated by templ - DO NOT EDIT. +// templ: version: v0.3.1036 package testprimitives //lint:file-ignore SA4006 This context is only used if a nested component is present. diff --git a/generator/test-raw-elements/template_templ.go b/generator/test-raw-elements/template_templ.go index be01a2a8b..f92c90798 100644 --- a/generator/test-raw-elements/template_templ.go +++ b/generator/test-raw-elements/template_templ.go @@ -1,5 +1,6 @@ // Code generated by templ - DO NOT EDIT. +// templ: version: v0.3.1036 package testrawelements //lint:file-ignore SA4006 This context is only used if a nested component is present. diff --git a/generator/test-script-expressions/template_templ.go b/generator/test-script-expressions/template_templ.go index 8adee59cb..797c6ccda 100644 --- a/generator/test-script-expressions/template_templ.go +++ b/generator/test-script-expressions/template_templ.go @@ -1,5 +1,6 @@ // Code generated by templ - DO NOT EDIT. +// templ: version: v0.3.1036 package testscriptexpressions //lint:file-ignore SA4006 This context is only used if a nested component is present. @@ -10,6 +11,11 @@ import templruntime "github.com/a-h/templ/runtime" func Script[T any](name string, data T) 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 + templ_7745c5c3_ArgsMap, templ_7745c5c3_ArgsOk := ctx.Value("_templ_args_map").(map[string]any) + if templ_7745c5c3_ArgsMap != nil && templ_7745c5c3_ArgsOk { + templruntime.SetTemplArg(templ_7745c5c3_ArgsMap, "name", name) + templruntime.SetTemplArg(templ_7745c5c3_ArgsMap, "data", data) + } if templ_7745c5c3_CtxErr := ctx.Err(); templ_7745c5c3_CtxErr != nil { return templ_7745c5c3_CtxErr } diff --git a/generator/test-script-inline/template_templ.go b/generator/test-script-inline/template_templ.go index 9f145d5c4..99c2a4b06 100644 --- a/generator/test-script-inline/template_templ.go +++ b/generator/test-script-inline/template_templ.go @@ -1,5 +1,6 @@ // Code generated by templ - DO NOT EDIT. +// templ: version: v0.3.1036 package testscriptinline //lint:file-ignore SA4006 This context is only used if a nested component is present. @@ -30,6 +31,10 @@ func withoutParameters() templ.ComponentScript { func InlineJavascript(a 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 + templ_7745c5c3_ArgsMap, templ_7745c5c3_ArgsOk := ctx.Value("_templ_args_map").(map[string]any) + if templ_7745c5c3_ArgsMap != nil && templ_7745c5c3_ArgsOk { + templruntime.SetTemplArg(templ_7745c5c3_ArgsMap, "a", a) + } if templ_7745c5c3_CtxErr := ctx.Err(); templ_7745c5c3_CtxErr != nil { return templ_7745c5c3_CtxErr } diff --git a/generator/test-script-usage-nonce/template_templ.go b/generator/test-script-usage-nonce/template_templ.go index 91c258d42..6f25d9b46 100644 --- a/generator/test-script-usage-nonce/template_templ.go +++ b/generator/test-script-usage-nonce/template_templ.go @@ -1,5 +1,6 @@ // Code generated by templ - DO NOT EDIT. +// templ: version: v0.3.1036 package testscriptusage //lint:file-ignore SA4006 This context is only used if a nested component is present. @@ -40,6 +41,10 @@ func onClick() templ.ComponentScript { func Button(text 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 + templ_7745c5c3_ArgsMap, templ_7745c5c3_ArgsOk := ctx.Value("_templ_args_map").(map[string]any) + if templ_7745c5c3_ArgsMap != nil && templ_7745c5c3_ArgsOk { + templruntime.SetTemplArg(templ_7745c5c3_ArgsMap, "text", text) + } if templ_7745c5c3_CtxErr := ctx.Err(); templ_7745c5c3_CtxErr != nil { return templ_7745c5c3_CtxErr } @@ -182,6 +187,10 @@ func conditionalScript() templ.ComponentScript { func Conditional(show bool) 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 + templ_7745c5c3_ArgsMap, templ_7745c5c3_ArgsOk := ctx.Value("_templ_args_map").(map[string]any) + if templ_7745c5c3_ArgsMap != nil && templ_7745c5c3_ArgsOk { + templruntime.SetTemplArg(templ_7745c5c3_ArgsMap, "show", show) + } if templ_7745c5c3_CtxErr := ctx.Err(); templ_7745c5c3_CtxErr != nil { return templ_7745c5c3_CtxErr } diff --git a/generator/test-script-usage/template_templ.go b/generator/test-script-usage/template_templ.go index 1c274e686..7c8c3a9f9 100644 --- a/generator/test-script-usage/template_templ.go +++ b/generator/test-script-usage/template_templ.go @@ -1,5 +1,6 @@ // Code generated by templ - DO NOT EDIT. +// templ: version: v0.3.1036 package testscriptusage //lint:file-ignore SA4006 This context is only used if a nested component is present. @@ -40,6 +41,10 @@ func onClick() templ.ComponentScript { func Button(text 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 + templ_7745c5c3_ArgsMap, templ_7745c5c3_ArgsOk := ctx.Value("_templ_args_map").(map[string]any) + if templ_7745c5c3_ArgsMap != nil && templ_7745c5c3_ArgsOk { + templruntime.SetTemplArg(templ_7745c5c3_ArgsMap, "text", text) + } if templ_7745c5c3_CtxErr := ctx.Err(); templ_7745c5c3_CtxErr != nil { return templ_7745c5c3_CtxErr } @@ -213,6 +218,10 @@ func conditionalScript() templ.ComponentScript { func Conditional(show bool) 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 + templ_7745c5c3_ArgsMap, templ_7745c5c3_ArgsOk := ctx.Value("_templ_args_map").(map[string]any) + if templ_7745c5c3_ArgsMap != nil && templ_7745c5c3_ArgsOk { + templruntime.SetTemplArg(templ_7745c5c3_ArgsMap, "show", show) + } if templ_7745c5c3_CtxErr := ctx.Err(); templ_7745c5c3_CtxErr != nil { return templ_7745c5c3_CtxErr } diff --git a/generator/test-spread-attributes/template_templ.go b/generator/test-spread-attributes/template_templ.go index 48feb71a2..c789eb5d2 100644 --- a/generator/test-spread-attributes/template_templ.go +++ b/generator/test-spread-attributes/template_templ.go @@ -1,5 +1,6 @@ // Code generated by templ - DO NOT EDIT. +// templ: version: v0.3.1036 package testspreadattributes //lint:file-ignore SA4006 This context is only used if a nested component is present. @@ -10,6 +11,10 @@ import templruntime "github.com/a-h/templ/runtime" func BasicTemplate(spread templ.Attributes) 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 + templ_7745c5c3_ArgsMap, templ_7745c5c3_ArgsOk := ctx.Value("_templ_args_map").(map[string]any) + if templ_7745c5c3_ArgsMap != nil && templ_7745c5c3_ArgsOk { + templruntime.SetTemplArg(templ_7745c5c3_ArgsMap, "spread", spread) + } if templ_7745c5c3_CtxErr := ctx.Err(); templ_7745c5c3_CtxErr != nil { return templ_7745c5c3_CtxErr } @@ -67,6 +72,10 @@ func BasicTemplate(spread templ.Attributes) templ.Component { func BasicTemplateOrdered(spread templ.OrderedAttributes) 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 + templ_7745c5c3_ArgsMap, templ_7745c5c3_ArgsOk := ctx.Value("_templ_args_map").(map[string]any) + if templ_7745c5c3_ArgsMap != nil && templ_7745c5c3_ArgsOk { + templruntime.SetTemplArg(templ_7745c5c3_ArgsMap, "spread", spread) + } if templ_7745c5c3_CtxErr := ctx.Err(); templ_7745c5c3_CtxErr != nil { return templ_7745c5c3_CtxErr } diff --git a/generator/test-string-errors/template_templ.go b/generator/test-string-errors/template_templ.go index f4a172e09..895a986e3 100644 --- a/generator/test-string-errors/template_templ.go +++ b/generator/test-string-errors/template_templ.go @@ -1,5 +1,6 @@ // Code generated by templ - DO NOT EDIT. +// templ: version: v0.3.1036 package teststringerrs //lint:file-ignore SA4006 This context is only used if a nested component is present. @@ -21,6 +22,10 @@ func funcWithError(in error) (s string, err error) { func TestComponent(err error) 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 + templ_7745c5c3_ArgsMap, templ_7745c5c3_ArgsOk := ctx.Value("_templ_args_map").(map[string]any) + if templ_7745c5c3_ArgsMap != nil && templ_7745c5c3_ArgsOk { + templruntime.SetTemplArg(templ_7745c5c3_ArgsMap, "err", err) + } if templ_7745c5c3_CtxErr := ctx.Err(); templ_7745c5c3_CtxErr != nil { return templ_7745c5c3_CtxErr } diff --git a/generator/test-string/template_templ.go b/generator/test-string/template_templ.go index 8468472ea..843903a60 100644 --- a/generator/test-string/template_templ.go +++ b/generator/test-string/template_templ.go @@ -1,5 +1,6 @@ // Code generated by templ - DO NOT EDIT. +// templ: version: v0.3.1036 package teststring //lint:file-ignore SA4006 This context is only used if a nested component is present. @@ -10,6 +11,10 @@ import templruntime "github.com/a-h/templ/runtime" func render(s 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 + templ_7745c5c3_ArgsMap, templ_7745c5c3_ArgsOk := ctx.Value("_templ_args_map").(map[string]any) + if templ_7745c5c3_ArgsMap != nil && templ_7745c5c3_ArgsOk { + templruntime.SetTemplArg(templ_7745c5c3_ArgsMap, "s", s) + } if templ_7745c5c3_CtxErr := ctx.Err(); templ_7745c5c3_CtxErr != nil { return templ_7745c5c3_CtxErr } diff --git a/generator/test-style-attribute/template_templ.go b/generator/test-style-attribute/template_templ.go index 5936d14ed..ee241fe0a 100644 --- a/generator/test-style-attribute/template_templ.go +++ b/generator/test-style-attribute/template_templ.go @@ -1,5 +1,6 @@ // Code generated by templ - DO NOT EDIT. +// templ: version: v0.3.1036 package teststyleattribute //lint:file-ignore SA4006 This context is only used if a nested component is present. @@ -10,6 +11,11 @@ import templruntime "github.com/a-h/templ/runtime" func Button[T any](style T, text 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 + templ_7745c5c3_ArgsMap, templ_7745c5c3_ArgsOk := ctx.Value("_templ_args_map").(map[string]any) + if templ_7745c5c3_ArgsMap != nil && templ_7745c5c3_ArgsOk { + templruntime.SetTemplArg(templ_7745c5c3_ArgsMap, "style", style) + templruntime.SetTemplArg(templ_7745c5c3_ArgsMap, "text", text) + } if templ_7745c5c3_CtxErr := ctx.Err(); templ_7745c5c3_CtxErr != nil { return templ_7745c5c3_CtxErr } diff --git a/generator/test-switch/template_templ.go b/generator/test-switch/template_templ.go index e25a6dfea..6aad4f0e5 100644 --- a/generator/test-switch/template_templ.go +++ b/generator/test-switch/template_templ.go @@ -1,5 +1,6 @@ // Code generated by templ - DO NOT EDIT. +// templ: version: v0.3.1036 package testswitch //lint:file-ignore SA4006 This context is only used if a nested component is present. @@ -10,6 +11,10 @@ import templruntime "github.com/a-h/templ/runtime" func render(input 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 + templ_7745c5c3_ArgsMap, templ_7745c5c3_ArgsOk := ctx.Value("_templ_args_map").(map[string]any) + if templ_7745c5c3_ArgsMap != nil && templ_7745c5c3_ArgsOk { + templruntime.SetTemplArg(templ_7745c5c3_ArgsMap, "input", input) + } if templ_7745c5c3_CtxErr := ctx.Err(); templ_7745c5c3_CtxErr != nil { return templ_7745c5c3_CtxErr } diff --git a/generator/test-switchdefault/template_templ.go b/generator/test-switchdefault/template_templ.go index a226611ac..868f5ff93 100644 --- a/generator/test-switchdefault/template_templ.go +++ b/generator/test-switchdefault/template_templ.go @@ -1,5 +1,6 @@ // Code generated by templ - DO NOT EDIT. +// templ: version: v0.3.1036 package testswitchdefault //lint:file-ignore SA4006 This context is only used if a nested component is present. @@ -10,6 +11,10 @@ import templruntime "github.com/a-h/templ/runtime" func template(input 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 + templ_7745c5c3_ArgsMap, templ_7745c5c3_ArgsOk := ctx.Value("_templ_args_map").(map[string]any) + if templ_7745c5c3_ArgsMap != nil && templ_7745c5c3_ArgsOk { + templruntime.SetTemplArg(templ_7745c5c3_ArgsMap, "input", input) + } if templ_7745c5c3_CtxErr := ctx.Err(); templ_7745c5c3_CtxErr != nil { return templ_7745c5c3_CtxErr } diff --git a/generator/test-templ-element/template_templ.go b/generator/test-templ-element/template_templ.go index c868e415d..3cdb31633 100644 --- a/generator/test-templ-element/template_templ.go +++ b/generator/test-templ-element/template_templ.go @@ -1,5 +1,6 @@ // Code generated by templ - DO NOT EDIT. +// templ: version: v0.3.1036 package testtemplelement //lint:file-ignore SA4006 This context is only used if a nested component is present. @@ -12,6 +13,10 @@ import "fmt" func wrapper(index int) 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 + templ_7745c5c3_ArgsMap, templ_7745c5c3_ArgsOk := ctx.Value("_templ_args_map").(map[string]any) + if templ_7745c5c3_ArgsMap != nil && templ_7745c5c3_ArgsOk { + templruntime.SetTemplArg(templ_7745c5c3_ArgsMap, "index", index) + } if templ_7745c5c3_CtxErr := ctx.Err(); templ_7745c5c3_CtxErr != nil { return templ_7745c5c3_CtxErr } diff --git a/generator/test-templ-in-go-template/template_templ.go b/generator/test-templ-in-go-template/template_templ.go index 2a87ce770..27cf5fb32 100644 --- a/generator/test-templ-in-go-template/template_templ.go +++ b/generator/test-templ-in-go-template/template_templ.go @@ -1,5 +1,6 @@ // Code generated by templ - DO NOT EDIT. +// templ: version: v0.3.1036 package testgotemplates //lint:file-ignore SA4006 This context is only used if a nested component is present. diff --git a/generator/test-text-inline-expression/template_templ.go b/generator/test-text-inline-expression/template_templ.go index 670d9adba..fb1a3205b 100644 --- a/generator/test-text-inline-expression/template_templ.go +++ b/generator/test-text-inline-expression/template_templ.go @@ -1,5 +1,6 @@ // Code generated by templ - DO NOT EDIT. +// templ: version: v0.3.1036 package testtextinlineexpression //lint:file-ignore SA4006 This context is only used if a nested component is present. diff --git a/generator/test-text-whitespace/template_templ.go b/generator/test-text-whitespace/template_templ.go index 80dafa3df..5ce60400d 100644 --- a/generator/test-text-whitespace/template_templ.go +++ b/generator/test-text-whitespace/template_templ.go @@ -1,5 +1,6 @@ // Code generated by templ - DO NOT EDIT. +// templ: version: v0.3.1036 package testtextwhitespace //lint:file-ignore SA4006 This context is only used if a nested component is present. @@ -159,6 +160,11 @@ const WhiteSpaceAroundTemplatedValuesExpected = `
templ allows whitespace ar func WhiteSpaceAroundTemplatedValues(prefix, statement 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 + templ_7745c5c3_ArgsMap, templ_7745c5c3_ArgsOk := ctx.Value("_templ_args_map").(map[string]any) + if templ_7745c5c3_ArgsMap != nil && templ_7745c5c3_ArgsOk { + templruntime.SetTemplArg(templ_7745c5c3_ArgsMap, "prefix", prefix) + templruntime.SetTemplArg(templ_7745c5c3_ArgsMap, "statement", statement) + } if templ_7745c5c3_CtxErr := ctx.Err(); templ_7745c5c3_CtxErr != nil { return templ_7745c5c3_CtxErr } diff --git a/generator/test-text/template_templ.go b/generator/test-text/template_templ.go index 4307dab42..922c50bb8 100644 --- a/generator/test-text/template_templ.go +++ b/generator/test-text/template_templ.go @@ -1,5 +1,6 @@ // Code generated by templ - DO NOT EDIT. +// templ: version: v0.3.1036 package testtext //lint:file-ignore SA4006 This context is only used if a nested component is present. @@ -10,6 +11,10 @@ import templruntime "github.com/a-h/templ/runtime" func BasicTemplate(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 + templ_7745c5c3_ArgsMap, templ_7745c5c3_ArgsOk := ctx.Value("_templ_args_map").(map[string]any) + if templ_7745c5c3_ArgsMap != nil && templ_7745c5c3_ArgsOk { + templruntime.SetTemplArg(templ_7745c5c3_ArgsMap, "name", name) + } if templ_7745c5c3_CtxErr := ctx.Err(); templ_7745c5c3_CtxErr != nil { return templ_7745c5c3_CtxErr } diff --git a/generator/test-void/template_templ.go b/generator/test-void/template_templ.go index a2552cc81..b61157634 100644 --- a/generator/test-void/template_templ.go +++ b/generator/test-void/template_templ.go @@ -1,5 +1,6 @@ // Code generated by templ - DO NOT EDIT. +// templ: version: v0.3.1036 package testvoid //lint:file-ignore SA4006 This context is only used if a nested component is present. diff --git a/generator/test-whitespace-around-go-keywords/template_templ.go b/generator/test-whitespace-around-go-keywords/template_templ.go index 0df8f0c0c..7b49688b7 100644 --- a/generator/test-whitespace-around-go-keywords/template_templ.go +++ b/generator/test-whitespace-around-go-keywords/template_templ.go @@ -1,5 +1,6 @@ // Code generated by templ - DO NOT EDIT. +// templ: version: v0.3.1036 package testwhitespacearoundgokeywords //lint:file-ignore SA4006 This context is only used if a nested component is present. @@ -12,6 +13,11 @@ import "fmt" func WhitespaceIsConsistentInIf(firstIf, secondIf bool) 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 + templ_7745c5c3_ArgsMap, templ_7745c5c3_ArgsOk := ctx.Value("_templ_args_map").(map[string]any) + if templ_7745c5c3_ArgsMap != nil && templ_7745c5c3_ArgsOk { + templruntime.SetTemplArg(templ_7745c5c3_ArgsMap, "firstIf", firstIf) + templruntime.SetTemplArg(templ_7745c5c3_ArgsMap, "secondIf", secondIf) + } if templ_7745c5c3_CtxErr := ctx.Err(); templ_7745c5c3_CtxErr != nil { return templ_7745c5c3_CtxErr } @@ -106,6 +112,10 @@ const WhitespaceIsConsistentInFalseIfExpected = ` func WhitespaceIsConsistentInFor(i int) 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 + templ_7745c5c3_ArgsMap, templ_7745c5c3_ArgsOk := ctx.Value("_templ_args_map").(map[string]any) + if templ_7745c5c3_ArgsMap != nil && templ_7745c5c3_ArgsOk { + templruntime.SetTemplArg(templ_7745c5c3_ArgsMap, "i", i) + } if templ_7745c5c3_CtxErr := ctx.Err(); templ_7745c5c3_CtxErr != nil { return templ_7745c5c3_CtxErr } diff --git a/runtime/runtime.go b/runtime/runtime.go index aaa4a2c48..456bff5c9 100644 --- a/runtime/runtime.go +++ b/runtime/runtime.go @@ -19,3 +19,12 @@ func GeneratedTemplate(f func(GeneratedComponentInput) error) templ.Component { return f(GeneratedComponentInput{ctx, w}) }) } + +// SetTemplArg stores value in m under key only if the key is not already set. +// This ensures that when components are nested, the outermost (first) component's +// arguments take precedence over any inner components with same-named parameters. +func SetTemplArg(m map[string]any, key string, value any) { + if _, exists := m[key]; !exists { + m[key] = value + } +}