How to make passport-authentication in Pug.js work?

Viewed 104

The if statement in ejs file works but in the pug file it doesnt works. what should I do to make it work ?

This is my pug file

<h1> LOGIN </H1>

 if messages.error 
    p!= messages.error

form(action="/login")
    legend Email 
        input(type="email" placeholder="Enter Email ID"  name="email" required)
        br
    legend Password 
        input(type="password" placeholder="Enter Password" name='password' required)
        br
    input(type="submit" value="Login")
p Or create new Account   
a(href="/signup") sign up 

This is my ejs file.

<h1>Login</h1>
<% if (messages.error) { %>
  <%= messages.error %>
<% } %>
<form action="/login" method="POST">
  <div>
    <label for="email">Email</label>
    <input type="email" id="email" name="email" required>
  </div>
  <div>
    <label for="password">Password</label>
    <input type="password" id="password" name="password" required>
  </div>
  <button type="submit">Login</button>
</form>
<a href="/register">Register</a>
1 Answers

Indentation is crucial in pug; there appears there's a single space before if messages.error.

EDIT 1: Can you try this?

h1 LOGIN

if messages.error 
    p!= messages.error

form(action="/login")
    legend Email 
        input(type="email" placeholder="Enter Email ID" id='email' name="email" required)
        br
    legend Password 
        input(type="password" placeholder="Enter Password" id='password' name='password' required)
        br
    input(type="submit" value="Login")
p Or create new Account   
a(href="/signup") sign up
Related