高洛峰2017-04-17 13:59:29
When you say good writing, it should be "editor", right? ^^, anyone who can write good code in the "compiler" must be very cool!
And it seems that it is not called jade
now, but is called: pug
.
Open a command line and install the pug
command tool first:
npm install pug-cli -g
in front of itIf it is an operating system other than
windows
, addsudo
Then write a template for 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.
Then in the command line, use the pug
command to escape it into the real html
:
pug -P test.pug
Then it automatically generated something like this 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
You don’t need me to teach you how to use it?
Of course, what I am introducing is an introduction for beginners. High-level usage is integrated into other project construction tools. Take your time, you won’t become fat if you eat it all in one go