I
I
IngwineForest2019-07-30 19:48:42
go
IngwineForest, 2019-07-30 19:48:42

How to make error text return in html/template when checking variable?

Greetings!
I use the Echo framework and unfortunately I'm completely confused, I'll try to explain from what I have at the moment.

func GetHandler(c echo.Context) error {
  return c.Render(200, "login.html", echo.Map{
    "Title": "Новая запись",
  })
}
func PostHandler(c echo.Context) error {
  name := c.FormValue("name")
  if len(name) == 0 {
    return c.Render(200, "login.html", echo.Map{
      "Title": "Новая запись",
      "Error": "Вы не ввели название",
    })
  }
}

This is an obvious town, I saw in one of the examples, a certain flash function is used to display a message:
if len(attr.Name) == 0 {
      helpers.FlashError(c, "Короткое сообщение")
      return c.Redirect(302, c.Request().URL.Path)
  }

I apologize for the possibly crooked wording of the question, but there is no way to either organize the error output as above, or add a key|value to echo.Map{} to use it in the context of html/template.
Thank you!

Answer the question

In order to leave comments, you need to log in

1 answer(s)
I
IngwineForest, 2019-08-01
@IngwineForest

If it is useful to someone else - https://www.alexedwards.net/blog/simple-flash-mess...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question