2014-10-10 84 views
0

我正在嘗試學習節點,角度,JavaScript,快遞和玉器。對於來自嚴格基於.net的代碼環境的我來說,這一切都非常新穎。使用玉和Eclipse的意外令牌'縮進'

所以我找到了一個教程,但已經在步驟2我遇到了麻煩。現在,這是一個直接複製粘貼,來自我在做一個新項目時自動創建的index.jade文件中的教程。

我插入下面的代碼到文件

doctype 5 
    html(lang='en) 
     head 
     meta(charset='utf-8') 
     meta(name='viewport', content='width=device-width,initial-scale=1, user-scalable=no') 
     title= title 
     link(rel='stylesheet', href='//netdna.bootstrapcdn.com/bootstrap/3.0.1/css/bootstrap.min.css') 
     link(rel='stylesheet', href='/stylesheets/style.css') 
     body 
     nav.navbar.navbar-inverse.navbar-fixed-top(role='navigation') 
      div.navbar-header 
      a.navbar-brand(href='#/polls')= title 
     div.container 
      div 

我也得到一個意外標記「縮進」的錯誤,對周圍的HTML的頭。現在我在使用Eclipse和Jade時非常環保,我不知道該怎麼做。我搜索了stackoverflow,但似乎無法找到任何與我的問題完全一樣的人,所以我很迷茫。任何提示將不勝感激。

+0

如果這完全像你的代碼裏面那樣,那麼你需要unindent所有的代碼,它會工作。 Jade代碼不能開始縮進。 – 2014-10-10 08:51:34

回答

1

您的文檔應該開始沒有任何空格(在文檔的左側右起),它可能是copypaste的副作用,這裏是它應該是什麼樣子:

doctype html 
html 
    head 
    meta(charset='utf-8') 
    meta(name='viewport', content='width=device-width,initial-scale=1, user-scalable=no') 
    title= title 
    link(rel='stylesheet', href='//netdna.bootstrapcdn.com/bootstrap/3.0.1/css/bootstrap.min.css') 
    link(rel='stylesheet', href='/stylesheets/style.css') 
    body 
    nav.navbar.navbar-inverse.navbar-fixed-top(role='navigation') 
     div.navbar-header 
     a.navbar-brand(href='#/polls')= title 
    div.container 
     div 
+0

這似乎工作謝謝:)但現在我得到一個新的錯誤,首先它說我必須使用html和不是文檔類型5,如果我然後更改doctype爲html我得到這個錯誤 500錯誤:C:\ Users \ Kristian \ workspace \ polls \ views \ index.jade:2 1 | doctype html> 2 | html(lang ='en)3 |頭4 | meta(charset ='utf-8')5 | meta(name ='viewport',content ='width = device-width,initial-scale = 1,user-scalable = no')字符串末尾沒有找到右括號。 – EclecticFish 2014-10-10 08:58:10

+0

看到我的編輯,你需要doctype html,然後html – xShirase 2014-10-10 09:04:13

+0

修復它!非常感謝你 – EclecticFish 2014-10-10 09:28:48

0

回答評論:

如果這完全像你的代碼裏面那樣,那麼你需要unindent所有的代碼,它會工作。 Jade代碼不能開始縮進。