diff --git a/.version b/.version index 0229a488e..f94611877 100644 --- a/.version +++ b/.version @@ -1 +1 @@ -0.2.608 \ No newline at end of file +0.2.610 \ No newline at end of file diff --git a/docs/docs/03-syntax-and-usage/03-attributes.md b/docs/docs/03-syntax-and-usage/03-attributes.md index 669996f0d..6460eb0e6 100644 --- a/docs/docs/03-syntax-and-usage/03-attributes.md +++ b/docs/docs/03-syntax-and-usage/03-attributes.md @@ -97,6 +97,7 @@ It's possible to spread any variable of type `templ.Attributes`. `templ.Attribut * If the value is a `bool`, the attribute is added as a boolean attribute if the value is true, e.g. `
`. * If the value is a `templ.KeyValue[string, bool]`, the attribute is added if the boolean is true, e.g. `
`. * If the value is a `templ.KeyValue[bool, bool]`, the attribute is added if both boolean values are true, as `
`. +* If the value is a `templ.ComponentScript`, the relevant ` + text -
+
+
text3
diff --git a/generator/test-spread-attributes/render_test.go b/generator/test-spread-attributes/render_test.go index 398feeaf5..275817ebe 100644 --- a/generator/test-spread-attributes/render_test.go +++ b/generator/test-spread-attributes/render_test.go @@ -12,32 +12,39 @@ import ( var expected string func Test(t *testing.T) { - component := BasicTemplate(templ.Attributes{ - // Should render as `bool` as the value is true, and the conditional render is also true. - "bool": templ.KV(true, true), - // Should not render, as the conditional render value is false. - "bool-disabled": templ.KV(true, false), - // Should render as `dateId="my-custom-id"`. - "dateId": "my-custom-id", - // Should render as `hx-get="/page"`. - "hx-get": "/page", - // Should render as `id="test"`. - "id": "test", - // Should not render, as the attribute value, and the conditional render value is false. - "no-bool": templ.KV(false, false), - // Should not render, as the conditional render value is false. - "no-text": templ.KV("empty", false), - // Should render as `nonshare`, as the value is true. - "nonshade": true, - // Should not render, as the value is false. - "shade": false, - // Should render text="lorem" as the value is true. - "text": templ.KV("lorem", true), - // Optional attribute based on result of func() bool. - "optional-from-func-false": func() bool { return false }, - // Optional attribute based on result of func() bool. - "optional-from-func-true": func() bool { return true }, - }) + component := BasicTemplate( + templ.Attributes{ + // Should render as `bool` as the value is true, and the conditional render is also true. + "bool": templ.KV(true, true), + // Should not render, as the conditional render value is false. + "bool-disabled": templ.KV(true, false), + // Should render as `dateId="my-custom-id"`. + "dateId": "my-custom-id", + // Should render as `hx-get="/page"`. + "hx-get": "/page", + // Should render as `id="test"`. + "id": "test", + // Should not render, as the attribute value, and the conditional render value is false. + "no-bool": templ.KV(false, false), + // Should not render, as the conditional render value is false. + "no-text": templ.KV("empty", false), + // Should render as `nonshare`, as the value is true. + "nonshade": true, + // Should not render, as the value is false. + "shade": false, + // Should render text="lorem" as the value is true. + "text": templ.KV("lorem", true), + // Optional attribute based on result of func() bool. + "optional-from-func-false": func() bool { return false }, + // Optional attribute based on result of func() bool. + "optional-from-func-true": func() bool { return true }, + // Should render a