0

I have been reading up on using YUIs template.micro here: precompiling YUI micro templates but cant see how its possible to return the JS to a templateName . js file. Alternatively, if its not designed to be saved to a templateName . js file - how is it designed to be used? Thanks in advance!

4

1 回答 1

0

文档向您展示了如何预编译,但缺少将其保存到磁盘的部分。

这是一个稍微修改的例子

// Load the YUI Template.Micro module.
var Micro = require('yui/template-micro').Template.Micro;

// Precompile a template string (pass any string you like here).
var precompiled = Micro.precompile(fs.readFileSync("./template.tmpl"));

// Save the compiled template to disk
fs.writeFileSync("./template.js", precompiled);

最后一步是重要的一步。

于 2013-11-11T23:51:13.593 回答