Skip to content

Instantly share code, notes, and snippets.

@limptwiglet
Created August 17, 2012 16:07
Show Gist options
  • Save limptwiglet/3380236 to your computer and use it in GitHub Desktop.
Save limptwiglet/3380236 to your computer and use it in GitHub Desktop.
Ember View builder
glob.sync(__dirname + '/public/js/templates/**/*.html').forEach(function (file) {
var path = file.split('/');
var fileName = path[path.length - 1];
var templateName = fileName.replace('.html', '');
var html = fs.readFileSync(file, 'utf8');
var dest = __dirname + '/public/js/.tmp/' + templateName + '.js';
html = html.replace(new RegExp('"', 'g'), '\\"');
html = html.replace(/[\r\n]/g, '');
html = 'Ember.TEMPLATES["' + templateName+ '"] = Ember.Handlebars.compile(\''+ html +'\');';
// Do what ever you want with the html
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment