From ae295659d0585593adde88db2e98aedec601eabd Mon Sep 17 00:00:00 2001 From: David Greenspan Date: Tue, 25 Jun 2013 12:13:42 -0700 Subject: [PATCH] lookup searches up for "data" arg try `{{> content}}` instead of `body` --- examples/unfinished/shark/client/shark.html | 10 ++++++++-- packages/ui/component.js | 21 +++++++++++++++++---- 2 files changed, 25 insertions(+), 6 deletions(-) diff --git a/examples/unfinished/shark/client/shark.html b/examples/unfinished/shark/client/shark.html index de88785a8b..a690789fc4 100644 --- a/examples/unfinished/shark/client/shark.html +++ b/examples/unfinished/shark/client/shark.html @@ -7,7 +7,9 @@

Hello {{name}}

{{#each items}} -
{{text}}
+ {{#divwrap}} +
{{text}}
+ {{/divwrap}} {{else}} Empty {{/each}} @@ -17,5 +19,9 @@ + + diff --git a/packages/ui/component.js b/packages/ui/component.js index 6d72e0f48b..6c3fce100e 100644 --- a/packages/ui/component.js +++ b/packages/ui/component.js @@ -516,7 +516,6 @@ _.extend(Component.prototype, { var result = null; var thisToBind = null; - var data; // XXX figure out what this should really do, // and how custom component classes should @@ -531,14 +530,28 @@ _.extend(Component.prototype, { result = If; } else if (id === 'each') { result = Each; + } else if (id === 'content') { + return self.lookup('body'); // XXX hack for trying `content` } else if (id in global) { result = global[id]; thisToBind = self.getArg('data') || null; } else if ((result = self.getArg(id))) { thisToBind = self; - } else if ((data = self.getArg('data'))) { - thisToBind = data; - result = data[id]; + } else { + // look for data arg, maybe in parent. stop as + // soon as we find a non-null value. + var comp = self; + var data = self.getArg('data'); + // `== null` means null or undefined + while (data == null && comp.parent) { + comp = comp.parent; + data = comp.getArg('data'); + } + + if (data != null) { + thisToBind = data; + result = data[id]; + } } if (thisToBind &&