在Jade中写纯HTML

时间:2015-06-16 12:58:15

标签: html pug

我认为可以在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...

2 个答案:

答案 0 :(得分:0)

显然是从管道开始|这应该工作

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

jade-lang.com/reference/plain-text

输出纯文本应如下所示:

pre
    <div>Stuff</div>

答案 1 :(得分: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.

编辑:

要在Jade中使用纯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/