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