2023-05-24 13:22:00 +03:00
|
|
|
package domain
|
|
|
|
|
|
|
|
import (
|
|
|
|
"io"
|
|
|
|
"text/template"
|
|
|
|
|
2023-12-08 16:30:55 +02:00
|
|
|
"github.com/zitadel/zitadel/internal/zerrors"
|
2023-05-24 13:22:00 +03:00
|
|
|
)
|
|
|
|
|
|
|
|
func renderURLTemplate(w io.Writer, tmpl string, data any) error {
|
|
|
|
parsed, err := template.New("").Parse(tmpl)
|
|
|
|
if err != nil {
|
2023-12-08 16:30:55 +02:00
|
|
|
return zerrors.ThrowInvalidArgument(err, "DOMAIN-oGh5e", "Errors.User.InvalidURLTemplate")
|
2023-05-24 13:22:00 +03:00
|
|
|
}
|
|
|
|
if err = parsed.Execute(w, data); err != nil {
|
2023-12-08 16:30:55 +02:00
|
|
|
return zerrors.ThrowInvalidArgument(err, "DOMAIN-ieYa7", "Errors.User.InvalidURLTemplate")
|
2023-05-24 13:22:00 +03:00
|
|
|
}
|
|
|
|
return nil
|
|
|
|
}
|