mirror of
https://github.com/meteor/meteor.git
synced 2026-05-02 03:01:46 -04:00
Fix html attributes in boilerplate generation.
We were not passing html attributes through to the Boilerplate object, so appcache manifest was never showing up in the <html> tag. Add 'extraData' to `Boilerplate.toHTML` so that we can specify the html attributes at request time.
This commit is contained in:
@@ -21,14 +21,18 @@ Boilerplate = function (arch, manifest, options) {
|
||||
);
|
||||
};
|
||||
|
||||
Boilerplate.prototype.toHTML = function () {
|
||||
// The 'extraData' argument can be used to extend 'self.baseData'. Its
|
||||
// purpose is to allow you to specify data that you might not know at
|
||||
// the time that you construct the Boilerplate object. (e.g. it is used
|
||||
// by 'webapp' to specify data that is only known at request-time).
|
||||
Boilerplate.prototype.toHTML = function (extraData) {
|
||||
var self = this;
|
||||
|
||||
if (! self.baseData || ! self.func)
|
||||
throw new Error('Boilerplate did not instantiate correctly.');
|
||||
|
||||
return "<!DOCTYPE html>\n" +
|
||||
Blaze.toHTML(Blaze.With(self.baseData,
|
||||
Blaze.toHTML(Blaze.With(_.extend(self.baseData, extraData),
|
||||
self.func));
|
||||
};
|
||||
|
||||
@@ -98,5 +102,3 @@ var _getTemplate = _.memoize(function (arch) {
|
||||
var filename = 'boilerplate_' + arch + '.html';
|
||||
return Assets.getText(filename);
|
||||
});
|
||||
|
||||
|
||||
|
||||
@@ -259,22 +259,23 @@ var boilerplateByArch = {};
|
||||
// XXX so far this function is always called with arch === 'web.browser'
|
||||
var memoizedBoilerplate = {};
|
||||
var getBoilerplate = function (request, arch) {
|
||||
var calculateMemoizationHash = function (request, arch) {
|
||||
var htmlAttributes = getHtmlAttributes(request);
|
||||
// The only thing that changes from request to request (for now) are
|
||||
// the HTML attributes (used by, eg, appcache) and whether inline
|
||||
// scripts are allowed, so we can memoize based on that.
|
||||
return JSON.stringify({
|
||||
inlineScriptsAllowed: inlineScriptsAllowed,
|
||||
htmlAttributes: htmlAttributes,
|
||||
arch: arch
|
||||
|
||||
var htmlAttributes = getHtmlAttributes(request);
|
||||
|
||||
// The only thing that changes from request to request (for now) are
|
||||
// the HTML attributes (used by, eg, appcache) and whether inline
|
||||
// scripts are allowed, so we can memoize based on that.
|
||||
var memHash = JSON.stringify({
|
||||
inlineScriptsAllowed: inlineScriptsAllowed,
|
||||
htmlAttributes: htmlAttributes,
|
||||
arch: arch
|
||||
});
|
||||
|
||||
if (! memoizedBoilerplate[memHash]) {
|
||||
memoizedBoilerplate[memHash] = boilerplateByArch[arch].toHTML({
|
||||
htmlAttributes: htmlAttributes
|
||||
});
|
||||
};
|
||||
|
||||
var memHash = calculateMemoizationHash(request, arch);
|
||||
|
||||
if (! memoizedBoilerplate[memHash])
|
||||
memoizedBoilerplate[memHash] = boilerplateByArch[arch].toHTML();
|
||||
}
|
||||
return memoizedBoilerplate[memHash];
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user