-
I have an app which uses htmx and I often need to render a main response body plus some out-of-band content to swap out for a different part of the page, in a single response body <!-- Template 1 --><div>Main template content</div>
<!-- Template 2 --><div id="other-part" hx-oob-swap="true">Some other part</div> so typically I want to do something like c.Render(http.StatusOK, "template-1", data1)
return c.Render(http.StatusOK, "template-2", data2) but sending the status code twice doesn't make sense and I get an error message that says c.Render(http.StatusOK, "template-1", data1)
return c.Echo().Renderer.Render(c.Response().Writer, "template-2", data2, c) Is there a function I'm missing or more idiomatic approach to handling situations like these? I'm relatively new to golang. Thanks! |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
Go templates can include other templates. so you could create template 3 that includes template 1 and template2 and render that. |
Beta Was this translation helpful? Give feedback.
Go templates can include other templates. so you could create template 3 that includes template 1 and template2 and render that.