a-h / templ

A language for writing HTML user interfaces in Go.
https://templ.guide/
MIT License
8.39k stars 277 forks source link

Render css classes inside <style></style> #953

Closed marianvlad closed 1 month ago

marianvlad commented 1 month ago

Hi,

I have a component Layout with a parameter called styles of type string. There is a way to use like this?

styles := "body { color: red; }"
<style>{ styles }</style> 

and return

<style>body { color: red; }</style>

instead

<style>{ styles }</style> 

✅ Found the solution

styles := "<style>body { color: red; }</style>"
@templ.Raw(styles)
lorypelli commented 3 weeks ago

thanks, it works!

lorypelli commented 3 weeks ago

I was searching for a solution since yesterday