如何使用 yeoman 生成器将数据传递到非 html 模板

How to pass data to a non html template with yeoman generator

我想将我的项目名称传递到许多不同的文件中,其中 none 个是 html 个文件。

是否可以对非 html 文件执行类似下面示例的操作?

writing: function() {
   // takes two arguments: sourcePath, destPath
   this.fs.copy('_someTpl', 'Jenkinsfile', {data: this.tplData});
}

或者有没有办法将数据写入 html 文件并在 Jenkinsfile 中读取 html 文件的内容?提前致谢!

Yeoman 不关心您正在复制哪种文件。对于 Yeoman,它只是文本文件。

我认为您的问题是使用 copy 而不是 copyTpl。只有copyTpl会在模板中注入数据。