Replies: 1 comment 1 reply
-
Yes, it would be really useful if the templ.Component implemented the .String() method. My usecase would be this: Afaik there is no out-of-the-box way to do this. |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hello,
I was working in a personal project that use gorilla Websockets. I decided to update the project to use templ, I was using the function WriteMessage that receive a slice of bytes. I started searching a way to get a []bytes for a Component and the closes I got was the function ToGoHTML, I knew I can convert template.HTML to a string and them to []bytes. After that, I saw the code of the function and release that from the buffer I can get []bytes without getting a template.HTML first and I implemented the function in my Project.
I thought I could be helpful to have a function that converts a templ.Component to a string and other one that do the same just to a []bytes. I would like created a PR with this two functions, basically those will be similar to the ToGoHTML implementation. Please let me know what do you think.
Kind regards
Beta Was this translation helpful? Give feedback.
All reactions