在命令行上预编译dust.js模板

gae*_*fan 3 javascript templates dust.js

我对使用dust.js感兴趣,并且出于效率原因我想要预编译模板.

为了自动化编译过程,我希望能够从命令行执行此操作.从网站上看,我似乎必须使用浏览器来编译模板.有命令行解决方案吗?

smf*_*ote 8

有一种方法可以使用命令行自动化编译过程.首先,你需要安装dustjs-linkedin:

$ npm install -g dustjs-linkedin
Run Code Online (Sandbox Code Playgroud)

然后你可以使用命令dustc:

$ dustc input_file.tl output_file.js
Run Code Online (Sandbox Code Playgroud)

您还可以使用--name标志为模板指定名称:

$ dustc --name=dust_fun dust_is_fun.tl dust_is_fun.js
Run Code Online (Sandbox Code Playgroud)

有关更多信息,请查看LinkedIn GitHub页面上的Dust .

dustc自2.6版本的dustjs以来已被完全重写(但语法几乎完全相同),此处提供了文档.