当我用 this.copyTpl 复制模板时,yeoman 打印引号的代码 cacharter 而不是引号......这里是我在做什么
在 index.js 中
this.dependencies["fontawesome"] = "4.2";
this.dependencies["jQuery"] = "~1.11.1";
this.dependencies["responsive-nav"] = "1.0.34";
this.dependencies["superfish"] = "1.7.5";
this.dep = JSON.stringify(this.dependencies);
console.log(this.dep)
display
{"fontawesome":"4.2","jQuery":"~1.11.1","responsive-nav":"1.0.34","superfish":"1.7.5"}
this.fs.copyTpl(
this.templatePath('_bower.json'),
this.destinationPath(projectPath +'/bower.json'),{
projectName: _.slugify(this.project_name),
dependencies: this.dep
}
);
结果文件
{"fontawesome":"4.2","jQuery":"~1.11.1","responsive-nav":"1.0.34","superfish":"1.7.5"},
为什么会发生这种情况,我需要额外的配置在哪里?我错过了什么?感谢帮助
最佳答案
<%=
传递给它的转义值以防止 XSS。
要输出原始输入,您需要使用 <%-
模板标签。
关于 Yeoman 使用的模板引擎的完整文档,位于 http://ejs.co/
关于yeoman 在模板中打印代码字符,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37106704/