Question

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!

Was it helpful?

Solution

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top