Pug(이전 이름은 Jade)는 간결하고 읽기 쉬운 문법을 가진 템플릿 엔진입니다. HTML을 작성하는 대신 들여쓰기를 사용하여 구조를 정의하며, JavaScript 코드를 삽입할 수 있습니다. Pug는 Node.js와 함께 사용되며, 특히 Express와의 호환성이 뛰어나 서버 측 애플리케이션을 구축하는 데 유용합니다.
npm install pug const express = require('express');
const app = express();
// Pug를 템플릿 엔진으로 설정
app.set('view engine', 'pug');
// views/index.pug
html
head
title= title
body
h1 Hello, #{name}!
app.get('/', (req, res) => {
res.render('index', { title: 'Homepage', name: 'John' });
});