1

我有一个相当大的 Metalsmith 项目,使用 Nunjucks 进行模板(即使用metalsmith-in-place,它使用jstransformer-nunjucks):

const Metalsmith       = require('metalsmith'),
      inplace          = require('metalsmith-in-place');

Metalsmith(__dirname)
  .metadata(metadata)
  .source('./src')
  .destination('./build')
  .use(inplace({
    engineOptions: {
      root: path.join(__dirname, 'src')
    }
  }))
  .build(function(err) {
    if (err) {
      throw err;
    }
  });

当我运行构建脚本时,我从具有“未知路径”的模板中收到模板错误:

> project@0.4.0 build ~/project
> node build.js

~/project/build.js:155
          throw err;
          ^

Template render error: (unknown path) [Line 13, Column 6]
  unknown block tag: greetingSection
    at Object._prettifyError (~/project/node_modules/nunjucks/src/lib.js:36:11)
    at Template.init (~/project/node_modules/nunjucks/src/environment.js:515:19)
    at Template.Obj (~/project/node_modules/nunjucks/src/object.js:64:15)
    at new Template (~/project/node_modules/nunjucks/src/environment.js:482:18)
    at Object.compile (~/project/node_modules/nunjucks/index.js:85:12)
    at Object.exports.compile (~/project/node_modules/jstransformer-nunjucks/index.js:50:29)
    at Transformer.render (~/project/node_modules/jstransformer/index.js:288:44)
    at resolve (~/project/node_modules/metalsmith-in-place/lib/index.js:60:33)
    at new Promise (<anonymous>)
    at render (~/project/node_modules/metalsmith-in-place/lib/index.js:29:10)

我不知道我的许多 Nunjucks 文件中的哪一个导致了错误。如何让 metalsmith-in-place 给我导致问题的文件路径?

4

0 回答 0