There are " + Players.find({online: true}).count() + - " players online.
"; - }); - document.body.appendChild(frag); - - // Server side: find all players that have been idle for a while, - // and mark them as offline. The count on the screen will - // automatically update on all clients. - Players.update({idleTime: {$gt: 30}}, {$set: {online: false}}); - -{{> api_box renderList}} - -Creates a `DocumentFragment` that automatically updates as the results -of a database query change. Most Meteor apps use `{{dstache}}#each}}` in -a template instead of calling this directly. - -`renderList` is more efficient than using `Meteor.render` to render HTML -for a list of documents. For example, if a new document is created in -the database that matches the query, a new item will be rendered and -inserted at the appropriate place in the DOM without re-rendering the -other elements. Similarly, if a document changes position in a sorted -query, the DOM nodes will simply be moved and not re-rendered. - -`docFunc` is called as needed to generate HTML for each document. If -you provide `elseFunc`, then whenever the query returns no results, it -will be called to render alternate content. You might use this to show -a message like "No records match your query." - -Each call to `docFunc` or `elseFunc` is run in its own reactive -computation so that if it has other external data dependencies, it will be -individually re-run when the data changes. - -Example: - - // List the titles of all of the posts that have the tag - // "frontpage". Keep the list updated as new posts are made, as tags - // change, etc. Display the selected post differently. - var frag = Meteor.renderList( - Posts.find({tags: "frontpage"}), - function(post) { - var style = Session.equals("selectedId", post._id) ? "selected" : ""; - // A real app would need to quote/sanitize post.name - return '