Skip to content

Commit

Permalink
For #1
Browse files Browse the repository at this point in the history
  • Loading branch information
tmeasday committed Apr 9, 2014
1 parent b40e9b0 commit 25617e1
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 1 deletion.
8 changes: 8 additions & 0 deletions layout-test.html
Original file line number Diff line number Diff line change
Expand Up @@ -54,3 +54,11 @@
footer
{{/contentFor}}
</template>

<template name="DefaultDataForLayout">
{{#with title="ok"}}
{{#Layout template="LayoutWithOneYield"}}
inner{{title}}
{{/Layout}}
{{/with}}
</template>
6 changes: 6 additions & 0 deletions layout-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,12 @@ Tinytest.add('layout - default main region using Layout template', function (tes
});
});

Tinytest.add('layout - default data context using Layout template', function (test) {
withRenderedComponent(Template.DefaultDataForLayout, function (cmp, screen) {
test.equal(screen.innerHTML.compact(), 'layoutinnerok', 'default data context should be outer data context');
});
});

Tinytest.add('layout - dynamic yield regions', function (test) {
withRenderedLayout({template: 'LayoutWithTwoYields'}, function (layout, screen) {
var renderedCount = 1;
Expand Down
8 changes: 7 additions & 1 deletion layout.js
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,13 @@ Layout = UI.Component.extend({
var tmplDep = new Deps.Dependency;

// get the initial data value
var data = Deps.nonreactive(function () { return self.get(); });
var data = Deps.nonreactive(function () {
// check parent incase we are rendered in isolation (e.g. by IR)
// -- we are assuming that the parent is a {{#with layoutTemplate=X
// so we want to skip past it for the data to be used by the yields
// see https://github.com/eventedmind/blaze-layout/issues/1
return (self.parent && self.parent.parent || self).get();
});
var dataDep = new Deps.Dependency;
var regions = this._regions = new ReactiveDict;
var content = this.__content;
Expand Down

0 comments on commit 25617e1

Please sign in to comment.