In Jade, how can I suppress the error if a variable does not exist?

Asked

Viewed 40 times

4

I’m trying to create a form to create a user, but I use the same form to edit. When I try to create a new user the app shows me an error because in the form fields it tries to get information from a user who obviously does not exist because I am creating and not editing information.

In PHP we use @$user->name to suppress errors, but how to do this with jade?

input.form-control(name='name',value=user.name)

1 answer

1

- if (typeof(user.name) !== 'undefined'){
  //-aqui você coloca o seu código
-}

I think that solves.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.