Write simple HTML in Jade

I thought it was possible to write pure HTML as input in Jade files, but it fails when trying.

For this HTML

div(ng-controller="TestController")

h1 Services list

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

div(ui-view)

      

I am getting the following error

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...

      

+3


source to share


2 answers


obviously starting from the pipe | this should work

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

      

jade-lang.com/reference/plain-text




The plain text output should look like this:

pre
    <div>Stuff</div>

      

0


source


Instead of just writing simple HTML to a .jade file, you need to use the Jade syntax for HTML files:

 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.

      

Edit:

To use regular HTML tags in Jade, you have basically 2 possibilities:



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

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

You can read more details here: http://jade-lang.com/reference/plain-text/

0


source







All Articles