From a5282ba140757f0a6c3ed52ba000aae57ef1ff99 Mon Sep 17 00:00:00 2001 From: Sashko Stubailo Date: Tue, 24 Feb 2015 14:29:09 -0800 Subject: [PATCH] Make Template.body be a normal template Fixes #3631 Instead of a collection of top-level views, which it was before --- templating.js | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/templating.js b/templating.js index 7e4efc50e97..ea835b63111 100644 --- a/templating.js +++ b/templating.js @@ -36,27 +36,25 @@ Template.__define__ = function (name, renderFunc) { }; // Define a template `Template.body` that renders its -// `contentViews`. `` tags (of which there may be +// `contentRenderFuncs`. `` tags (of which there may be // multiple) will have their contents added to it. /** - * @summary The [template object](#templates_api) representing your `` tag. + * @summary The [template object](#templates_api) representing your `` + * tag. * @locus Client */ Template.body = new Template('body', function () { - var parts = Template.body.contentViews; - // enable lookup by setting `view.template` - for (var i = 0; i < parts.length; i++) - parts[i].template = Template.body; - return parts; + var view = this; + return _.map(Template.body.contentRenderFuncs, function (func) { + return func.apply(view); + }); }); -Template.body.contentViews = []; // array of Blaze.Views +Template.body.contentRenderFuncs = []; // array of Blaze.Views Template.body.view = null; Template.body.addContent = function (renderFunc) { - var kind = 'body_content_' + Template.body.contentViews.length; - - Template.body.contentViews.push(Blaze.View(kind, renderFunc)); + Template.body.contentRenderFuncs.push(renderFunc); }; // This function does not use `this` and so it may be called