javascript 个文件中的 Yeoman 占位符

Yeoman placeholder in javascript files

如何将 Yeoman 中的 placeholder 用于 js 文件?我试着添加它

  writing: function () {
    this.fs.copy(
      this.templatePath('portanova_template'),
      this.destinationPath(this.projectName)

    );
    if(this.answer) {
      this.fs.copy(
      this.templatePath('externalTemplate'),
        this.destinationPath(this.projectName+'/app'),
       {
        title: this.projectName
      }
      );
    }
  },

并且在刚刚添加的 js 文件中

"<%= title %>"

任何需要的地方。但它似乎不起作用.. 有什么想法吗?

您需要使用this.fs.copyTpl()否则模板标签不会被处理。