我正在尝试重构我的应用程序以使用jade而不是ejs,但在设置登录表单时遇到了一些问题。
这是我在 ejs 中的原始表单:
<% if (message) { %>
<p><%= message %></p>
<% } %>
<form class="form-horizontal" action='/login' method="POST" id="loginForm">
<fieldset>
<div id="legend">
<legend class="">Login</legend>
</div>
<div class="control-group">
<!-- Username -->
<label class="control-label" for="username">Username</label>
<div class="controls">
<input type="text" id="username" name="username" placeholder="" class="input-xlarge">
</div>
</div>
<div class="control-group">
<!-- Password-->
<label class="control-label" for="password">Password</label>
<div class="controls">
<input type="password" id="password" name="password" placeholder="" class="input-xlarge">
</div>
</div>
<div class="control-group">
<!-- session-->
<label class="control-label" for="rememberme">Remember Me</label>
<div class="controls">
<input type="checkbox" name="rememberme"/>
</div>
</div>
<div class="control-group">
<!-- Button -->
<div class="controls">
<button class="btn btn-success">Login</button>
</div>
</div>
</fieldset>
</form>
这是我的新玉形式:
extends layout
block content
if message
p= message
form(class='form-horizontal',action='/login',method='POST',id='loginForm')
fieldset
div#legand
legend Login
div.control-group
label(for='username',class='control-label') Username
div.controls
input(type='text',id='username',name='username',placeholder='Username',class='input-xlarge')
div.control-group
label(for='password',class='control-label') Password
div.controls
input(type='text',id='password',name='password',placeholder='Password',class='input-xlarge')
div.control-group
label(for='rememberme',class='control-label') Remember Me
div.controls
input(type='checkbox',name='rememberme')
div.control-group
div.controls
input(type='submit',class='btn btn-success') Login
Codekit 抛出错误:
/Applications/CodeKit.app/Contents/Resources/engines/jade/lib/runtime.js:173
throw err;
^
Error: /Users/sm/Documents/Projects/Web_Applications/App/app/views/login.jade:27
25|
26|
> 27|
Invalid indentation, you can use tabs or spaces but not both
at Object.Lexer.indent (/Applications/CodeKit.app/Contents/Resources/engines/jade/lib/lexer.js:672:15)
at Object.Lexer.next (/Applications/CodeKit.app/Contents/Resources/engines/jade/lib/lexer.js:770:15)
at Object.Lexer.blank (/Applications/CodeKit.app/Contents/Resources/engines/jade/lib/lexer.js:179:19)
at Object.Lexer.next (/Applications/CodeKit.app/Contents/Resources/engines/jade/lib/lexer.js:744:15)
at Object.Lexer.blank (/Applications/CodeKit.app/Contents/Resources/engines/jade/lib/lexer.js:179:19)
at Object.Lexer.next (/Applications/CodeKit.app/Contents/Resources/engines/jade/lib/lexer.js:744:15)
at Object.Lexer.lookahead (/Applications/CodeKit.app/Contents/Resources/engines/jade/lib/lexer.js:106:46)
at Object.Parser.lookahead (/Applications/CodeKit.app/Contents/Resources/engines/jade/lib/parser.js:115:23)
at Object.Parser.peek (/Applications/CodeKit.app/Contents/Resources/engines/jade/lib/parser.js:92:17)
at Object.Parser.tag (/Applications/CodeKit.app/Contents/Resources/engines/jade/lib/parser.js:666:30)
我怎样才能克服这个缩进错误并让这个表格工作?我只使用制表符,没有空格,所以我不明白问题是什么。