diff --git a/.version b/.version index 7c39898db..1969284cb 100644 --- a/.version +++ b/.version @@ -1 +1 @@ -0.2.552 \ No newline at end of file +0.2.557 \ No newline at end of file diff --git a/cmd/templ/generatecmd/testwatch/watch_test.go b/cmd/templ/generatecmd/testwatch/watch_test.go index a202ac617..79f11584f 100644 --- a/cmd/templ/generatecmd/testwatch/watch_test.go +++ b/cmd/templ/generatecmd/testwatch/watch_test.go @@ -334,7 +334,7 @@ func waitForUrl(url string) (err error) { var tries int for { time.Sleep(time.Second) - if tries > 5 { + if tries > 20 { return err } tries++ diff --git a/cmd/templ/migratecmd/main.go b/cmd/templ/migratecmd/main.go index fd3bd686c..bf6e9fbb3 100644 --- a/cmd/templ/migratecmd/main.go +++ b/cmd/templ/migratecmd/main.go @@ -134,7 +134,7 @@ func migrateV1TemplateFileNodeToV2TemplateFileNode(in v1.TemplateFileNode) (out }, nil case v1.CSSTemplate: var t v2.CSSTemplate - t.Name.Value = n.Name.Value + t.Expression.Value = n.Name.Value t.Properties = make([]v2.CSSProperty, len(n.Properties)) for i, p := range n.Properties { t.Properties[i], err = migrateV1CSSPropertyToV2CSSProperty(p) diff --git a/docs/docs/03-syntax-and-usage/10-css-style-management.md b/docs/docs/03-syntax-and-usage/10-css-style-management.md index 83c39ac95..0811a5441 100644 --- a/docs/docs/03-syntax-and-usage/10-css-style-management.md +++ b/docs/docs/03-syntax-and-usage/10-css-style-management.md @@ -170,6 +170,34 @@ The CSS class is given a unique name the first time it is used, and only rendere The class name is autogenerated, don't rely on it being consistent. ::: +### CSS component arguments + +CSS components can also require function arguments. + +```templ title="component.templ" +package main + +css loading(percent int) { + width: { fmt.Sprintf("%d%%", percent) }; +} + +templ index() { +
+
+} +``` + +```html title="Output" + +
+ +
+``` + ### CSS Middleware The use of CSS templates means that ` +
+ CSS components can be used with arguments. +
+ +
+ CSS components can be used with arguments. +
+ diff --git a/generator/test-css-usage/template.templ b/generator/test-css-usage/template.templ index 262f27473..3068d6b30 100644 --- a/generator/test-css-usage/template.templ +++ b/generator/test-css-usage/template.templ @@ -1,5 +1,7 @@ package testcssusage +import "fmt" + // Constant class. templ StyleTagsAreSupported() {