#5.3 Extending Templates

jini.choi·2022년 7월 8일
0

유튜브 클론코딩

목록 보기
20/27

inheritance(상속)

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

  • 일종의 베이스를 만들어줌(레이아웃의 베이시 혹은 HTML의 베이스)
  • 모든 파일들이 그 베이스에서부터 확장해 나감
  1. base.pug 생성
doctype html
html(lang="ko")
    head
        title Wetube
    body
        h1 Base!
        include partials/footer.pug
  1. home.pug, watch.pug, edit.pug 내용 지우고 base를 확장(extends)하게 함
    extends base.pug

  2. extens를하면 모든 페이지의 내용이 base.pug로 됨, 이제 blcok을 사용

block

  • block은 템플릿의 창문같은 것(무언가를 집어 넣을수 있는 곳)
  1. base.pug 안에 block을 만들어줌
doctype html
html(lang="ko")
    head
        block head
    body
        block content
        include partials/footer.pug
  1. home.pug에서 content 블록안에 어떤 내용을 넣고싶다면 아래와 같이 입력
extends base.pug

block head
    title Home | Wetube

block content
    h1 Home!
profile
개발짜🏃‍♀️

0개의 댓글