Output String? #97
Answered
by
markuswustenberg
chrismalek
asked this question in
Q&A
-
I may be missing something obvious. I am working with a framework that just needs a string for the HTML output. Is there a method / function / trick to do that with a node? |
Beta Was this translation helpful? Give feedback.
Answered by
markuswustenberg
May 20, 2022
Replies: 2 comments 1 reply
-
Every |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
markuswustenberg
-
Great thanks. I end up doing something like this: buf := new(bytes.Buffer)
// gocomponent node generated "above the fold".
personHTML.Render(buf)
// Iris web framework needs a string
ctx.Negotiation().JSON(person).XML(person).HTML(buf.String())
ctx.Negotiate(nil)
|
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
Every
Node
has aRender
method, which you can pass any writer to. A good writer could bestrings.Builder
for you purpose. 😊