Skip to content
\n

so typically I want to do something like

\n
c.Render(http.StatusOK, \"template-1\", data1)\nreturn c.Render(http.StatusOK, \"template-2\", data2)
\n

but sending the status code twice doesn't make sense and I get an error message that says response already committed. To get around that I've been doing something like

\n
c.Render(http.StatusOK, \"template-1\", data1)\nreturn c.Echo().Renderer.Render(c.Response().Writer, \"template-2\", data2, c)
\n

Is there a function I'm missing or more idiomatic approach to handling situations like these? I'm relatively new to golang. Thanks!

","upvoteCount":1,"answerCount":1,"acceptedAnswer":{"@type":"Answer","text":"

Go templates can include other templates. so you could create template 3 that includes template 1 and template2 and render that.

","upvoteCount":2,"url":"https://github.com/labstack/echo/discussions/2686#discussioncomment-10951577"}}}

Strategy for rendering multiple templates in a single response #2686

Answered by aldas
0ui asked this question in Q&A
Discussion options

You must be logged in to vote

Go templates can include other templates. so you could create template 3 that includes template 1 and template2 and render that.

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@0ui
Comment options

@aldas
Comment options

Answer selected by 0ui
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants