2017-07-23 45 views
1

最近我在看YouTube上的一些視頻教程,並且遇到了這個JADE的東西,我該如何安裝和使用它來進行我的web開發?如何安裝和使用Jade

我把它搜索了一遍,但沒有找到一個適當的網站,教導一步一步繼續。而網站jade-lang.com不可用。我從網站上做到了這一點,但node.js拋出了一些錯誤。下面的截圖:

enter image description here

+0

錯誤字面上告訴你這個問題,它會變得多簡單?! – DavidG

回答

1

first玉已被棄用,玉新名字是哈巴狗欲瞭解更多信息,請查看此鏈接

pug documentation

second安裝你在你的文件夾中的項目安裝後的哈巴狗創建一個新的文件夾到您的項目和創建你的項目file.pug中的文件和right click+ shiftopen command window here寫這個命令pug file.pug你寫這之後哈巴狗寫這個命令npm install pug -g命令時,它會生成一個新文件file.html

Third寫這個命令pug input.pug input.html --watch --pretty

--watch在文件保存後編譯代碼。帕格

--pretty寫代碼的HTML(組織代碼)不minimized code

的格式寫的哈巴狗標籤寫入標籤的名稱,如

  • html標籤,我們將編譯爲<html></html>

  • a(href='#' target='_blank') link編譯爲<a href="#" target="_blank">link</a>

  • a(href='#' target=''): img(src='' alt='')編譯爲<a href="#" target=""><img src="" alt=""/></a>
  • 寫評論// this is a comment編譯成<!-- this is a comment -->
  • 編寫的類名稱和標記,例如內容p.demo this is a paragraph編譯成<p class="demo"> this is a paragraph</p>
  • 寫ID和內容標籤例如p#demo this is a paragraph編譯爲<p id="demo"> this is a paragraph</p>
  • 編寫一個函數

    mixin list ul li foo li bar li baz

使用此功能編寫的函數+list名字,並編譯成

<ul> 
    <li>foo</li> 
    <li>bar</li> 
    <li>baz</li> 
    </ul> 

包括文件寫入include file_name

最後這是哈巴狗代碼示例

html 
    head 
     title Hello 
     link(href='' rel='stylesheet' type='text/css') 
    body 

     //this is a comment 
     p.item hello 
     p#item 

     br/ 

     a(href='#' target=''): img(src='' alt='') 
     // to start a new line 
     | 
     | 
     a(href='google.com') Google 
     // write a function 
     mixin list 
      ul 
      li foo 
      li bar 
      li baz 
     // use function 
     +list 
     // include file 
     include content 

欲瞭解更多有關帕格的信息,請點擊此鏈接pug full documentation