learning express step(十二)

learning express view engine function

const express = require('express');
const app = express();

app.set('views','./views');
app.set('view engine', 'pug');

app.get('/', function(req, res){
    res.render('index',{title: 'hey', message: 'hello panzidong using views'});
});
app.listen(3000);

views/index.pug

html
  head
    title= title
  body
    h1= message

result:

原文地址:https://www.cnblogs.com/lianghong881018/p/11015051.html