view multi templ component
This commit is contained in:
@@ -1,10 +1,32 @@
|
||||
package utils
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"net/http"
|
||||
|
||||
"github.com/a-h/templ"
|
||||
"github.com/labstack/echo/v4"
|
||||
)
|
||||
|
||||
func ViewMulti(c echo.Context, cmp []templ.Component) error {
|
||||
var stringHtml string = ""
|
||||
buf := new(bytes.Buffer)
|
||||
|
||||
var err error
|
||||
for _, x := range cmp {
|
||||
err = x.Render(c.Request().Context(), buf)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
stringHtml += buf.String()
|
||||
}
|
||||
|
||||
c.Response().Header().Set(echo.HeaderContentType, echo.MIMETextHTML)
|
||||
|
||||
return c.String(http.StatusOK, stringHtml)
|
||||
|
||||
}
|
||||
|
||||
func View(c echo.Context, cmp templ.Component) error {
|
||||
c.Response().Header().Set(echo.HeaderContentType, echo.MIMETextHTML)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user