mirror of
https://github.com/meteor/meteor.git
synced 2026-05-02 03:01:46 -04:00
lookup searches up for "data" arg
try `{{> content}}` instead of `body`
This commit is contained in:
@@ -7,7 +7,9 @@
|
||||
<h1>Hello {{name}}</h1>
|
||||
|
||||
{{#each items}}
|
||||
<div>{{text}}</div>
|
||||
{{#divwrap}}
|
||||
<div>{{text}}</div>
|
||||
{{/divwrap}}
|
||||
{{else}}
|
||||
<strong>Empty</strong>
|
||||
{{/each}}
|
||||
@@ -17,5 +19,9 @@
|
||||
</body>
|
||||
|
||||
<template name="twice">
|
||||
{{> body foo=123}} {{{middle}}} {{> body foo=456}}
|
||||
{{> content foo=123}} {{{middle}}} {{> content foo=456}}
|
||||
</template>
|
||||
|
||||
<template name="divwrap">
|
||||
<div>{{> content}}</div>
|
||||
</template>
|
||||
|
||||
@@ -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 &&
|
||||
|
||||
Reference in New Issue
Block a user