mirror of
https://github.com/meteor/meteor.git
synced 2026-05-02 03:01:46 -04:00
Fix UI.contentBlock data context
This commit is contained in:
@@ -617,8 +617,17 @@ Blaze.Each = function (argFunc, contentFunc, elseFunc) {
|
||||
return eachView;
|
||||
};
|
||||
|
||||
Blaze.SetParentView = function (parentView, contentFunc) {
|
||||
var view = Blaze.View('SetParentView', contentFunc);
|
||||
Blaze.InOuterTemplateScope = function (templateView, contentFunc) {
|
||||
var view = Blaze.View('InOuterTemplateScope', contentFunc);
|
||||
var parentView = templateView.parentView;
|
||||
|
||||
// Hack so that if you call `{{> foo bar}}` and it expands into
|
||||
// `{{#with bar}}{{> foo}}{{/with}}`, and then `foo` is a template
|
||||
// that inserts `{{> UI.contentBlock}}`, the data context for
|
||||
// `UI.contentBlock` is not `bar` but the one enclosing that.
|
||||
if (parentView.__isTemplateWith)
|
||||
parentView = parentView.parentView;
|
||||
|
||||
view.onCreated(function () {
|
||||
this.parentView = parentView;
|
||||
});
|
||||
|
||||
@@ -133,7 +133,7 @@ _.extend(CodeGen.prototype, {
|
||||
|
||||
if (path[0] === 'UI' &&
|
||||
(path[1] === 'contentBlock' || path[1] === 'elseBlock')) {
|
||||
includeCode = 'Blaze.SetParentView(view, function () { return '
|
||||
includeCode = 'Blaze.InOuterTemplateScope(view, function () { return '
|
||||
+ includeCode + '; })';
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user