node.js - 无需模板的 Yeoman 复制目录

标签 node.js yeoman yeoman-generator

我正在使用 yeoman 为我的应用创建脚手架。

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

this.directory('views/static/views', '.views/static/views');

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

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

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

最佳答案

我想通了。 使用 this.fs.copy 递归复制而不使用模板。

writing: function () {
    this.fs.copy(
      this.templatePath('views/static/views'),
      this.destinationPath('.views/static/views')
    );
  }

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

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

关于node.js - 无需模板的 Yeoman 复制目录,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33940207/

相关文章:

javascript - 导出模块并在导入时抛出错误/停止执行

gruntjs - Grunt 删除index.html 内容

javascript - 从节点脚本调用时如何跳过 Yeoman 生成器步骤

javascript - 如何在 Yeoman 中使用 promises 进行递归提示?

javascript - async/await : asynchronous array transformation using Array.prototype.map(有效)与Array.prototype.filter(无效)

javascript - 检测 Node.js 中的硬链接(hard link)

angularjs - Yeoman 生成的 Angular 应用程序中的 .bowerrc 文件在哪里?

node.js - 如何控制spawnCommand方法的执行位置

node.js - nock 库 - 如何匹配任何 url

express - 如何将 Yeoman 与 Express/Jade/Stylus 一起使用?