From 8ab66ff2557a34eb0eeeef5a12e9f444ac6032bb Mon Sep 17 00:00:00 2001 From: David Glasser Date: Mon, 2 Dec 2013 15:57:09 -0800 Subject: [PATCH] Stop using handlebars in the bundler. The dev bundle contains a copy of the handlebars NPM module solely for creating app.html. This is separate from the NPM module used by the handlebars NPM package. On the shark branch, we no longer use the handlebars NPM module for Meteor template (it is being replaced by Spacebars), so in preparation for that, we'll remove this barely-used build-time dependency on handlebars. A subsequent commit will remove it from the dev bundle. Once the Spacebars API has fully settled (eg, it has been merged to devel), we should get rid of this ad hoc templating and replace it with Spacebars, either in webapp_server (driven entirely by program.json) or by using unipackage.load in bundler. --- tools/app.html.in | 17 ----------------- tools/bundler.js | 40 ++++++++++++++++++++++++++++++---------- 2 files changed, 30 insertions(+), 27 deletions(-) delete mode 100644 tools/app.html.in diff --git a/tools/app.html.in b/tools/app.html.in deleted file mode 100644 index e2bc250d0f..0000000000 --- a/tools/app.html.in +++ /dev/null @@ -1,17 +0,0 @@ - - - -{{#each stylesheets}} -{{/each}} - -##RUNTIME_CONFIG## - -{{#each scripts}} -{{/each}} - -{{{head_extra}}} - - -{{{body_extra}}} - - diff --git a/tools/bundler.js b/tools/bundler.js index 9c45d1c6f4..54c54b735e 100644 --- a/tools/bundler.js +++ b/tools/bundler.js @@ -769,19 +769,39 @@ _.extend(ClientTarget.prototype, { self.css[0].setUrlToHash(".css"); }, + // XXX Instead of packaging the boilerplate in the client program, the + // template should be part of WebApp, and we should make sure that all + // information that it needs is in the manifest (ie, make sure to include head + // and body). Then it will just need to do one level of templating instead + // of two. Alternatively, use spacebars with unipackage.load here. generateHtmlBoilerplate: function () { var self = this; - var templatePath = path.join(__dirname, "app.html.in"); - var template = watch.readAndWatchFile(self.watchSet, templatePath); - - var f = require('handlebars').compile(template.toString()); - return new Buffer(f({ - scripts: _.pluck(self.js, 'url'), - stylesheets: _.pluck(self.css, 'url'), - head_extra: self.head.join('\n'), - body_extra: self.body.join('\n') - }), 'utf8'); + var html = []; + html.push('\n' + + '\n' + + '\n'); + _.each(self.css, function (css) { + html.push(' \n'); + }); + html.push('\n\n##RUNTIME_CONFIG##\n\n'); + _.each(self.js, function (js) { + html.push(' \n'); + }); + html.push('\n\n'); + html.push(self.head.join('\n')); // unescaped! + html.push('\n' + + '\n' + + '\n'); + html.push(self.body.join('\n')); // unescaped! + html.push('\n' + + '\n' + + '\n'); + return new Buffer(html.join(''), 'utf8'); }, // Output the finished target to disk