2016-11-05 62 views
-1

它一直显示警报......我的unless errors出了什么问题?如果声明不在帕格工作

我的路线

app.set('view engine', 'pug') 

app.get('/', function (req, res) { 
    res.render('index', { errors: false }) 
}) 

Index.pug

<!DOCTYPE html> 
<html lang="nl"> 
    <head> 
    <meta charset="utf-8"> 
    <meta http-equiv="X-UA-Compatible" content="IE=edge"> 
    <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no"> 
    <!-- The above 3 meta tags *must* come first in the head; any other head content must come *after* these tags --> 
    <meta name="description" content=""> 
    <meta name="author" content=""> 
    <!--<link rel="icon" href="../../favicon.ico">--> 

    <title>Signin Template for Bootstrap</title> 

    <!-- Bootstrap core CSS --> 
    <link href="css/bootstrap.min.css" rel="stylesheet"> 

    <!-- Custom styles for this template --> 
    <link href="signin.css" rel="stylesheet"> 
    </head> 

    <body> 

    <div class="container"> 
     unless errors 
     .alert.alert-danger 
      <strong>Oh snap!</strong> Change a few things up and try submitting again. 

     <form class="form-signin" method="POST" action="/"> 
     <h2 class="form-signin-heading">Login om verder te gaan</h2> 
     <label for="inputEmail" class="sr-only">Email adres</label> 
     <input type="email" id="inputEmail" class="form-control" placeholder="Email adres" required autofocus> 
     <label for="inputPassword" class="sr-only">Wachtwoord</label> 
     <input type="password" id="inputPassword" class="form-control" placeholder="Wachtwoord" required> 
     <div class="checkbox"> 
      <label> 
      <input type="checkbox" value="remember-me"> Onthoudt mij 
      </label> 
     </div> 
     <button class="btn btn-lg btn-primary btn-block" type="submit">Login</button> 
     </form> 

    </div> <!-- /container --> 

    <script src="js/ie10-viewport-bug-workaround.js"></script> 
    </body> 
</html> 
+0

难道你不是指“如果错误”?如果错误等于false,则“除非错误”将返回true。 (我不知道哈巴狗,但这似乎是问题) – yvanavermaet

回答

1

帕格使用缩进来定义的标记嵌套,没有任何标记的打开或关闭:

doctype default 
html 
    head 
     meta(charset="utf-8") 
     meta(http-equiv="X-UA-Compatible", content="IE=edge") 
     meta(name="viewport", content="width=device-width, initial-scale=1, shrink-to-fit=no") 
     //- The above 3 meta tags *must* come first in the head; any other head content must come *after* these 

     meta(name="description", content="") 
     meta(name="author", content="") 

     title Signin Template for Bootstrap 
     link(rel="stylesheet", href="/css/bootstrap.min.css") 
    body 
     div(class="container") 
      - if errors 
       .alert.alert-danger 
        strong Oh snap! 
        | Change a few things up and try submitting again. 


      form(class="form-signin", method="POST", action="/") 
       h2(class="form-signin-heading") Login: 
       label(for="inputEmail", class="sr-only") Email address 
       input(type="email", id="inputEmail", class="form-control", placeholder="Email address", required autofocus) 
       label(for="inputPassword", class="sr-only") Password 
       input(type="password", id="inputPassword", class="form-control", required) 
       div(class="checkbox") 

,并继续与您的模板。