如果声明不在哈巴狗工作

时间:2016-11-05 13:21:36

标签: node.js express pug

它会一直显示警告......我的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>

1 个答案:

答案 0 :(得分:1)

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

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")

继续使用您的模板。