Replies: 3 comments
-
I'm sorry, I don't understand what you've written. Can you try to explain please? Perhaps some examples would help? On point 1, since templ is just creating HTML, you can include styles with On point 2, I'm not sure what you mean by including CSS classes, and that they're transformed. On the third point... I think you're referring to this from the docs, and that you'd like this to happen automatically? c1 := className()
handler := NewCSSMiddleware(httpRoutes, c1)
http.ListenAndServe(":8000", handler) I'm not sure how you think "the template" ... "is aware of the CSS classes at this point". I don't know what you think a template is, or how it would be aware of CSS classes. I think you think that since templ generates all CSS components in a package, there could be some sort of "render all the CSS" feature. Well, maybe, except CSS can be changed dynamically at runtime as per https://github.com/a-h/templ/pull/484/files - a long planned feature. On your point about "simply introduce a CSS input and output directive" - I don't know what you mean by "a CSS input and output directive". I'll move this to a discussion, since this isn't a clear issue. You might also want to consider the issue title "Lack of proper CSS handling". |
Beta Was this translation helpful? Give feedback.
-
Sorry, tired and brain Zzzzz. "the template" = Templ ... Point 1 ... 3 = Summary of existing features, however, all are missing a unified CSS style output. Feature 3 requires developers to specify the CSS class for each CSS class, which makes it seem redundant, especially for larger projects. Our project has over 70 templ files, each containing between 5 to 30 CSS tags, converting these to CSS classes for a more streamlined "single file html/css" experience (think tailwind without the need for tailwind) becomes a daunting task, when NewCSSMiddleware need manual providing the templ css class. While we understand that we can directly use style elements, as programmers, we know that the process can be significantly simplified by utilizing the CSS class feature, and having templ generating a single style file. Templ has access to the CSS class information during generation, so it would be logical to generate a single CSS output. If this functionality exists, it isn't clearly documented? We hope this explanation provides more clarity. |
Beta Was this translation helpful? Give feedback.
-
I'm confused by Should you define the middleware differently for CSS Elements vs CSS Components? Would love to see more examples if possible. Thank you! |
Beta Was this translation helpful? Give feedback.
-
After reviewing the manual, we identified a deficiency in the handling of included CSS.
The question arises, why is this so? The template automatically generates all files upon initial startup. It is aware of the CSS classes at this point. Any update that triggers a re-rendering of the templates will provide a unique class (composed of filename + css name) to replace or remove existing css classes.
Wouldn't it be more logical to eliminate NewCSSMiddleware and simply introduce a CSS input and output directive?
Beta Was this translation helpful? Give feedback.
All reactions