index.html.erb。 jade 如下所示:
<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 :(得分: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>