HTML-CSS
npm install -g pug-cli
。-w -o -P
。-w
: 表示wacth,為監聽某個folder下的pug檔。-o
: 表示output,為監聽某個pug檔改變時,同時新生成html並存放於folder下。-P
: 表示生成的html檔必須分隔明確。$ pug -w './pug檔的folder' -o '輸出html檔的folder' -P
//
即可。
doctype html
html
head
body
p test content
<!DOCTYPE html>
<html>
<head></head>
<body>
<p>test content</p>
</body>
</html>
html
head
body
p.
Test
Content
p Other Content
<!DOCTYPE html>
<html>
<head></head>
<body>
<p>
Test
Content
</p>
<p>Other Content</p>
</body>
</html>
id class
屬性 : 用selector宣告
id
: 可以直接使用『#idName』在tag後面。class
: 可以直接使用『.className』在tag後面。
doctype html
html
head
body
p.Test-Class.
Test
Content
p#Test-id.Test-Class Other Content
CSS
屬性 :
()
緊接在tag後面,()
內的CSS寫法同原生。
input(
type= 'checkbox'
name= 'agreement'
)
-
後加入加入JS的expression,僅限單行。
input(
type='text'
name='user'
class={5>2 ? 'Test-01' : 'Test-02'}
)
-- const Test=['Test-01', 'Test-02']
input(
type='password'
class={7>3 ? Test[0] : Test[1]}
)
&attribute=value
設定。
- const Test={color:'red', background-color: 'black' }
- const Test01={href:'http://localhost3030', alt="test"}
p(
style=Test
)
a&attribute=Test01
()
包住一切的東東。
head
link(rel='stylesheet' href='./style.css')
style.
Test{
color : red
}
for iterVar in iterableThing
。
for n in ['Test-01', 'Test-03', 'Test-03']
p=n
for n, i in ['Test-01', 'Test-03', 'Test-03']
p=i+'-'+n
for value, key in {name:'Steven', age: 20}
p=key+'-'+value
if的語法 :
if(空格)JS expression
case的語法 :
- const