2015-06-16 24 views
3

我認爲可以在Jade文件中編寫純HTML作爲輸入,但在嘗試時出現錯誤。在Jade中寫明文HTML

對於這個HTML

div(ng-controller="TestController") 

h1 Services list 

ul(ng-model="test") 
    li(ng-repeat="item in items") 
     a 
      | {{ item.name }} 

div(ui-view) 

我收到以下錯誤

Running "watch" task 
Waiting... 
>> File "app/frontend/views/home.jade" changed. 

Running "jade:compile" (jade) task 
>> Error: app/frontend/views/home.jade:2 
>>  1| <b>hello </b> test 
>> > 2| <ul ng-model="test"> 
>> 
>> unexpected token "indent" 
Warning: Jade failed to compile "app/frontend/views/home.jade". 
>> Destination not written because compiled files were empty. 
>> 5 files created. 

Running "watch" task 
Waiting... 
+0

燦你向我們展示更多的代碼?我希望看到該文件的標題(其中!!!標記是) – daZza

+0

沒有更多的代碼,我只是嘗試在HTML文件中寫入翡翠文件 – user567

+0

您的意思是這是您家中的所有代碼。玉檔案?在那種情況下,我們找到了錯誤的原因;-) – daZza

回答

0

顯然是與管道開始|這應該工作

| Plain text can include <strong>html</strong> 
p 
    | It must always be on its own line 

jade-lang.com/reference/plain-text


1.4.3純文本應該是這樣的:

pre 
    <div>Stuff</div> 
+0

我不能只是把普通的HTML標籤,應該輸出原樣? – user567

+0

你的意思是你想輸出代碼爲純文本?試試'pre'標籤 – AlexG

0

而不是隻寫純HTML代碼到.jade文件()你」我們需要在HTML文件中使用Jade語法:

doctype html 
html(lang="en") 
    head 
    title= pageTitle 
    script(type='text/javascript'). 
     if (foo) { 
     bar(1 + 5) 
     } 
    body 
    h1 Jade - node template engine 
    #container.col 
     if youAreUsingJade 
     p You are amazing 
     else 
     p Get on it! 
     p. 
     Jade is a terse and simple 
     templating language with a 
     strong focus on performance 
     and powerful features. 

編輯:

要使用內玉純HTML標籤你基本上有兩種方式:

p Plain text can include <strong>html</strong>

| Plain text can include <strong>html</strong> p | It must always be on its own line

您可以檢查進一步的細節在這裏:http://jade-lang.com/reference/plain-text/

+0

但我想寫純HTML我不想使用玉語法。所以這是不可能的? – user567

+0

你可以(查看我的編輯或AlexG的回答)。但是,您仍然需要使用正確的文件頭,否則Jade不會正確解釋這些內容。 – daZza