toranb / ember-template-compiler

An npm module for the ember-template-compiler.js file that ships with ember.js
MIT License
30 stars 23 forks source link

Commandline usage? #28

Closed liclac closed 9 years ago

liclac commented 9 years ago

Is there any chance you could make this callable from the commandline?

Something like /path/to/compiler /path/to/infile.hbs just spitting out the compiled output to stdout. Or is this already possible, and I'm just not seeing how?

toranb commented 9 years ago

The api is that simple actually - see the below 3 lines for more detail but you can provide the path to your hbs file - read that into your node program and ask this project to "precompile" it


var compiler = require('ember-template-compiler');
var template = fs.readFileSync('foo.handlebars').toString();
var compiledFunction = compiler.precompile(template, false);
console.log(compiledFunction); //you could return this to stdout /etc