【问题标题】:Yeoman copy directory without templating无模板的 Yeoman 复制目录
【发布时间】:2015-11-26 13:41:29
【问题描述】:

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

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

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

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

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

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

【问题讨论】:

    标签: node.js yeoman yeoman-generator


    【解决方案1】:

    我想通了。 使用 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' }
        );
      }
    

    【讨论】:

    • 太棒了!我需要两者的结合,谢谢你的信息。
    猜你喜欢
    • 1970-01-01
    • 2017-05-11
    • 1970-01-01
    • 2014-03-28
    • 2012-08-21
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多