Home  >  Q&A  >  body text

node.js - koa2 template engine rendering failure

The code is as shown in the figure. The expected result should be that the title has changed and the title is named node.
But in actual operation, the title is <%= title %>, which means the template engine does not work?

ringa_leeringa_lee2736 days ago625

reply all(3)I'll reply

  • 怪我咯

    怪我咯2017-05-16 13:34:02

    It seems that your index.js does not have a template engine set? Like the jade template engine, html files should be .jade files, not .html.

    reply
    0
  • 習慣沉默

    習慣沉默2017-05-16 13:34:02

    I agree with you, should I save the index.html file as an index.jade file? The jade template has been upgraded, save it as index.pug and try it.

    reply
    0
  • 怪我咯

    怪我咯2017-05-16 13:34:02

    gg, my mistake, the brackets were placed in the wrong place, disturbing everyone.

    app.use(views(path.join(__dirname, './views'), {
      map: {
        html: 'underscore'
      }
    }))

    Just change it to this way

    reply
    0
  • Cancelreply