我有一个带有角数据和CRUD操作的示例项目。我在grunt web上查看了Project支架,但是我找不到任何符合我需要的javascript模板.
我看到了init.copyAndProcess,这是我想要的,但我不需要什么改进。首先,我需要在js文件中带有条件句的模板,比如(伪代码):
{if prop.selectAllButton}
//declare header render on Datatables in several lines of code{/if}
此外,还会有10或20个选项,并且它可以随着列数的增加或通过创建虚拟列而增长。因此,我希望props对象在文件上,而不是在cli上被提示。
表不是以角的方式呈现的。
提前谢谢。阿智。
发布于 2016-02-15 13:20:27
现在我明白了,如果我从脚手架上搬出来使用yeoman,我的问题就很容易回答了.
在yo文件中,我可以在初始化阶段读取我的configFile,例如:
initializing: function () {
this.pkg = require('../package.json');
this.dtconfig = require(this.options['config-file-location']);
},
其中'config-file-location‘是cli的一个参数。
在编写阶段,我使用dtconfig作为copyTpl的参数:
scripts: function () {
this.fs.copyTpl(
this.templatePath('main.js'),
this.destinationPath('app/scripts/main.js'),
{//Parameters
selectAllButton: this.dtconfig.selectAllButton
}
);
它们,在templates/main.js文件中:
<% if (selectAllButton) { %>
//apply selectaAll header render for dt.
https://stackoverflow.com/questions/35321172
复制相似问题