mirror of
https://github.com/meteor/meteor.git
synced 2026-05-02 03:01:46 -04:00
start of real (cursor-based) Each
This commit is contained in:
@@ -104,13 +104,13 @@ Either = UIComponent.extend({
|
||||
elseContent: Span
|
||||
}),
|
||||
{ type: Span });
|
||||
buf(new _UI.Each({
|
||||
/* buf(new _UI.Each({
|
||||
content: UIComponent.extend({
|
||||
render: function (buf) {
|
||||
buf("<div>Each ", String(this.data()), "</div>");
|
||||
}
|
||||
})
|
||||
}));
|
||||
}));*/
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
@@ -34,16 +34,6 @@ _UI.If = Component.extend({
|
||||
}
|
||||
});
|
||||
|
||||
_UI.Each = Component.extend({
|
||||
typeName: 'Each',
|
||||
render: function (buf) {
|
||||
var self = this;
|
||||
buf(self.content(function () { return 0; })),
|
||||
buf(self.content(function () { return 1; }));
|
||||
buf(self.content(function () { return 2; }));
|
||||
}
|
||||
});
|
||||
|
||||
_UI.Counter = Component.extend({
|
||||
typeName: "Counter",
|
||||
fields: {
|
||||
|
||||
49
packages/ui/each.js
Normal file
49
packages/ui/each.js
Normal file
@@ -0,0 +1,49 @@
|
||||
var Component = UIComponent;
|
||||
|
||||
_UI.Each = Component.extend({
|
||||
typeName: 'Each',
|
||||
render: function (buf) {
|
||||
var self = this;
|
||||
|
||||
// XXX support arrays too.
|
||||
// For now, we assume the data is a database cursor.
|
||||
var cursor = self.data();
|
||||
// XXX also support `null`
|
||||
|
||||
|
||||
|
||||
var self = this;
|
||||
buf(self.content(function () { return 0; })),
|
||||
buf(self.content(function () { return 1; }));
|
||||
buf(self.content(function () { return 2; }));
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
// Function equal to LocalCollection._idStringify, or the identity
|
||||
// function if we don't have LiveData. Converts item keys (i.e. DDP
|
||||
// keys) to strings for storage in an OrderedDict.
|
||||
var idStringify;
|
||||
|
||||
// XXX not clear if this is the right way to do a weak dependency
|
||||
// now, post-linker
|
||||
if (typeof LocalCollection !== 'undefined') {
|
||||
idStringify = function (id) {
|
||||
if (id === null)
|
||||
return id;
|
||||
else
|
||||
return LocalCollection._idStringify(id);
|
||||
};
|
||||
} else {
|
||||
idStringify = function (id) { return id; };
|
||||
}
|
||||
|
||||
// XXX duplicated code from minimongo.js.
|
||||
var applyChanges = function (doc, changeFields) {
|
||||
_.each(changeFields, function (value, key) {
|
||||
if (value === undefined)
|
||||
delete doc[key];
|
||||
else
|
||||
doc[key] = value;
|
||||
});
|
||||
};
|
||||
@@ -182,7 +182,7 @@ Each = Component.extend({
|
||||
var idStringify;
|
||||
|
||||
// XXX not clear if this is the right way to do a weak dependency
|
||||
// now, on the linker branch
|
||||
// now, post-linker
|
||||
if (typeof LocalCollection !== 'undefined') {
|
||||
idStringify = function (id) {
|
||||
if (id === null)
|
||||
|
||||
@@ -20,6 +20,7 @@ Package.on_use(function (api) {
|
||||
'render.js',
|
||||
'dom.js',
|
||||
'forms.js',
|
||||
'each.js',
|
||||
'components.js',
|
||||
|
||||
'component.js', 'renderbuffer.js',
|
||||
|
||||
Reference in New Issue
Block a user