Nodejs基础之consolidate
- 模板引擎库,可以从npm上下载
- 基础用法
const consolidate = require('consolidate')
const app = express()
app.engine('html', consolidate.ejs) // 指定模板引擎,可以指定多个
app.set('view engine', 'html') // 设置默认扩展名,可以没有
app.('views', _dirname+'/views') // 模板文件位置
app.get('/',function(){
res.render('index.html', {variable: 'variable'}) // 第二个参数为模板传递变量
})