【问题标题】:Handlebars didn't render HTMLHandlebars 没有呈现 HTML
【发布时间】: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 &lt;h1&gt;Home&lt;/h1&gt; 它显示&lt;h1&gt;Home&lt;/h1&gt;

【问题讨论】:

    标签: javascript node.js express handlebars.js


    【解决方案1】:

    我错过了一个括号。应该是

    {{{body}}}
    

    【讨论】:

      猜你喜欢
      • 2017-08-02
      • 2013-04-24
      • 1970-01-01
      • 2017-03-15
      • 2016-02-15
      • 2020-05-02
      • 1970-01-01
      • 2018-08-14
      • 2015-01-27
      相关资源
      最近更新 更多