#5.2 Partials

jini.choi·2022년 7월 5일
0

유튜브 클론코딩

목록 보기
19/27

https://pugjs.org/api/getting-started.html

pug에 javascript사용하기

  • js코드는 유저의 브라우저로 가지 않고 유저가 보기전에 평범한 텍스트로 변환됨, 이것이 바로 렌더링이라는 것

Pug 반복문제

페이지별로 pug를 작성하다보면 header나 footer같은 경우 계속 반복해서 작성하고, 수정할때마다 모든 페이지를 수정해야되는 번거러움이 있다. 이것을 해결하기 위해 Partial에 대해 알아보자

Partial

https://pugjs.org/language/includes.html

  1. 고유의 footer.pug 파일 생성 후 footer내용 작성 (/views/partials/footer.pug)
    footer © #{new Date().getFullYear()} Wetube

  2. 페이지 중 footer가 들어가는 부분에 include해주기

doctype html
html(lang="ko")
    head
        title Wetube
    body
        h1 Watch Video!
        include partials/footer.pug
profile
개발짜🏃‍♀️

0개의 댓글