2015-07-02 40 views
0

index.html.erb。 在我的Rails應用程序玉樣子:玉遇到正常的HTML時拋出錯誤

<p id="notice"><%= notice %></p> 

<h1>0.9 beta</h1> 

.row 
    .column.small-4 
    Text1 
    .column.small-8 
    Text2 


<div class="flexcontainer"> 
    <div class="button"><%= button_to 'Provision eingeben', new_provision_path, class: 'button success radius large' %></div> 
    <div class="button"><%= button_to 'Ergebnis berechnen', 'provisions/results', method: :post, class: 'button success radius large' %></div> 
    <div class="button"><%= button_to 'Alle Einträge löschen', 'provisions/clearAll', method: :post, data: { confirm: 'Sind Sie sicher?' },class: 'button alert radius large' %></div> 
</div> 
<div class="space"></div> 

<table> 
    <thead> 
    <tr> 
     <th>Versicherung</th> 
     <th>Betrag</th> 
     <th>Teilhaber</th> 

,並給我上生成以下錯誤:

/usr/local/lib/node_modules/jade/lib/runtime.js:240 
    throw err; 
     ^
Error: /home/marc/Projects/provisionen2/app/views/provisions/index.html.erb.jade:13 
    11| 
    12| <div class="flexcontainer"> 
    > 13| <div class="button"><%= button_to 'Provision eingeben', new_provision_path, class: 'button success radius large' %></div> 
    14| <div class="button"><%= button_to 'Ergebnis berechnen', 'provisions/results', method: :post, class: 'button success radius large' %></div> 
    15| <div class="button"><%= button_to 'Alle Einträge löschen', 'provisions/clearAll', method: :post, data: { confirm: 'Sind Sie sicher?' },class: 'button alert radius large' %></div> 
    16| </div> 

unexpected token "indent" 
    at Parser.parseExpr (/usr/local/lib/node_modules/jade/lib/parser.js:254:15) 
    at Parser.parse (/usr/local/lib/node_modules/jade/lib/parser.js:122:25) 
    at parse (/usr/local/lib/node_modules/jade/lib/index.js:104:21) 
    at Object.exports.compile (/usr/local/lib/node_modules/jade/lib/index.js:205:16) 
    at handleTemplateCache (/usr/local/lib/node_modules/jade/lib/index.js:174:25) 
    at Object.exports.compileFile (/usr/local/lib/node_modules/jade/lib/index.js:309:10) 
    at renderFile (/usr/local/lib/node_modules/jade/bin/jade.js:237:19) 
    at fs.watchFile.persistent (/usr/local/lib/node_modules/jade/bin/jade.js:136:5) 
    at Array.forEach (native) 
    at Object.<anonymous> (/usr/local/lib/node_modules/jade/bin/jade.js:135:9) 
[Finished in 2.2s with exit code 8] 
[cmd: ['jade', '/home/marc/Projects/provisionen2/app/views/provisions/index.html.erb.jade', '--pretty']] 
[dir: /home/marc/Projects/provisionen2/app/views/provisions] 
[path: /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/home/marc/.rvm/bin] 

所以,很顯然它不喜歡孩子div的壓痕。 錯誤發生在後續的div,當我不縮進有問題的div ... 任何想法,爲什麼這是什麼?

回答

0

您直接將html嵌入到Jade中。嵌入純文本或html使用塊(DOT)語法。請參閱reference

<p id="notice"><%= notice %></p> 

<h1>0.9 beta</h1> 

.row 
    .column.small-4 
    Text1 
    .column.small-8 
    Text2 

div. 
    <div class="flexcontainer"> 
    <div class="button"><%= button_to 'Provision eingeben', new_provision_path, class: 'button success radius large' %></div> 
    <div class="button"><%= button_to 'Ergebnis berechnen', 'provisions/results', method: :post, class: 'button success radius large' %></div> 
    <div class="button"><%= button_to 'Alle Einträge löschen', 'provisions/clearAll', method: :post, data: { confirm: 'Sind Sie sicher?' },class: 'button alert radius large' %></div> 
    </div> 
    <div class="space"></div>