Yeoman复制目录没有模板化

Rob*_*pta 8 node.js yeoman yeoman-generator

我正在使用yeoman为我的应用程序创建一个脚手架.

我想递归复制所有目录,这就是我使用this.directory方法的原因

this.directory('views/static/views', '.views/static/views');
Run Code Online (Sandbox Code Playgroud)

现在每当我运行它时都会显示错误 <%= title %> in file index.html during copying is not defined.

<%= title %>不是模板的一部分,但我将其用于其他目的.

我想在使用this.directory方法复制时禁用模板.

Rob*_*pta 22

我明白了.在this.fs.copy没有模板的情况下递归使用副本.

writing: function () {
    this.fs.copy(
      this.templatePath('views/static/views'),
      this.destinationPath('.views/static/views')
    );
  }
Run Code Online (Sandbox Code Playgroud)

现在,当模板化正确的语法应该是

writing: function () {
    this.fs.copyTpl(
      this.templatePath('index.html'),
      this.destinationPath('public/index.html'),
      { title: 'Templating with Yeoman' }
    );
  }
Run Code Online (Sandbox Code Playgroud)