Heim > Fragen und Antworten > Hauptteil
高洛峰2017-04-17 13:59:29
你说的写好应该是“编辑器”吧?^^,能在“编译器”里写好代码的,想必应该很屌!
而且现在好像也不叫jade
,改叫:pug
了。
打开一个命令行,先安装pug
命令工具:
npm install pug-cli -g
如果是非
windows
的操作系统,再前面加sudo
然后写一个pug
的模板:
test.pug
doctype html
html(lang="en")
head
title= pageTitle
script(type='text/javascript').
if (foo) bar(1 + 5)
body
h1 Pug - node template engine
#container.col
if youAreUsingPug
p You are amazing
else
p Get on it!
p.
Pug is a terse and simple templating language with a
strong focus on performance and powerful features.
然后在命令行里,使用pug
命令将其转义成真正的html
:
pug -P test.pug
然后就自动生成了这个样子的html
:
<!DOCTYPE html>
<html lang="en">
<head>
<title></title>
<script type="text/javascript">if (foo) bar(1 + 5)</script>
</head>
<body>
<h1>Pug - node template engine</h1>
<p class="col" id="container">
<p>Get on it!</p>
<p>
Pug is a terse and simple templating language with a
strong focus on performance and powerful features.
</p>
</p>
</body>
</html>
html
该怎么用,不用我教吧?
当然我介绍的这是小白入门。高阶用法,都是都是集成在其他项目构建工具里的。慢慢来吧,一口气肯定吃不成个胖子