带有 grunt 的动态数据表
Dynamic Datatables with grunt
我有一个带有 angular-datatables 和 CRUD 操作的示例项目。我查看了 grunt web 上的 Project Scaffolding,但找不到任何符合我需要的 javascript 模板...
我看到 init.copyAndProcess 这正是我想要的,但我需要对此进行一些改进。首先,我想在我的 js 文件中使用带有条件语句的模板,例如(伪代码):
{if prop.selectAllButton}
//declare header render on Datatables in several lines of code{/if}
此外,将有 10 或 20 个选项,并且它可以随着列数或通过创建虚拟列而增加。所以,我希望 props 对象在文件中,而不是在 cli 上提示。
table 未以 angular 方式呈现。
提前致谢。
志.
现在我发现,如果我离开 grunt 脚手架并使用 yeoman,我的问题就有点容易回答了...
在 yo 文件中,我可以在初始化阶段读取我的配置文件,例如:
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.
我有一个带有 angular-datatables 和 CRUD 操作的示例项目。我查看了 grunt web 上的 Project Scaffolding,但找不到任何符合我需要的 javascript 模板...
我看到 init.copyAndProcess 这正是我想要的,但我需要对此进行一些改进。首先,我想在我的 js 文件中使用带有条件语句的模板,例如(伪代码):
{if prop.selectAllButton}
//declare header render on Datatables in several lines of code{/if}
此外,将有 10 或 20 个选项,并且它可以随着列数或通过创建虚拟列而增加。所以,我希望 props 对象在文件中,而不是在 cli 上提示。
table 未以 angular 方式呈现。
提前致谢。 志.
现在我发现,如果我离开 grunt 脚手架并使用 yeoman,我的问题就有点容易回答了...
在 yo 文件中,我可以在初始化阶段读取我的配置文件,例如:
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.