【发布时间】:2021-06-18 16:34:29
【问题描述】:
我创建了一个快速项目。我使用快速车把作为视图引擎,但它不起作用。它呈现纯文本。
这是我的 app.js
app.use(morgan('combined'))
// Template engine
app.engine('handlebars', handle({
extname: '.handlebars'
}));
app.use(express.static(path.join(__dirname, 'public')))
app.set('view engine', 'handlebars');
app.set('views', path.join(__dirname, 'resources/views'))
app.get('/', (req, res) => {
res.render('home')
})
app.listen(port, () => {
console.log(`Example app listening at http://localhost:${port}`)
})
main.handlebars
<body>
{{body}}
</body>
home.handlebars
<h1>Home</h1>
它显示<h1>Home</h1>
【问题讨论】:
标签: javascript node.js express handlebars.js