Domanda

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!

È stato utile?

Soluzione

The docs show you how to precompile but it lacks the part where you save it to disk.

Here's a slightly modified example

// 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);

That last step is the important one.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top