Skip to content

Instantly share code, notes, and snippets.

@aaronj1335
Last active December 17, 2015 05:39
Show Gist options
  • Select an option

  • Save aaronj1335/5559916 to your computer and use it in GitHub Desktop.

Select an option

Save aaronj1335/5559916 to your computer and use it in GitHub Desktop.
meteor exception
Exception from Deps recompute: Error: Can't create second landmark in same branch
at Object.Spark.createLandmark (http://localhost:3000/packages/spark/spark.js?4af332696fb84f1c71f2e678ad0a267755b2b828:1169:13)
at http://localhost:3000/packages/templating/deftemplate.js?9369dfa782cc1c8cd4d568925617249ec480b84f:116:24
at Object.Spark.labelBranch (http://localhost:3000/packages/spark/spark.js?4af332696fb84f1c71f2e678ad0a267755b2b828:1114:14)
at Object.Meteor._def_template.partial [as row] (http://localhost:3000/packages/templating/deftemplate.js?9369dfa782cc1c8cd4d568925617249ec480b84f:115:22)
at http://localhost:3000/packages/handlebars/evaluate.js?742a34cf3479d95600582786665b53c0eba4f7d9:352:48
at Object.Spark.labelBranch (http://localhost:3000/packages/spark/spark.js?4af332696fb84f1c71f2e678ad0a267755b2b828:1114:14)
at branch (http://localhost:3000/packages/handlebars/evaluate.js?742a34cf3479d95600582786665b53c0eba4f7d9:311:20)
at template (http://localhost:3000/packages/handlebars/evaluate.js?742a34cf3479d95600582786665b53c0eba4f7d9:351:20)
at Array.forEach (native)
at Function._.each._.forEach (http://localhost:3000/packages/underscore/underscore.js?6d71e6711255f43c0de8090f2c8b9f60534a699b:79:11)
Handlebars.registerHelper('each_with_previous', function(cursor, fn) {
var previous;
return cursor.map(function(item) {
return fn({
previous: previous,
item: previous = item
});
});
});
Template.messages.beingViewed = function() {
var pageSize = 100;
var page = Session.get('page');
return messages.find({}, {limit: pageSize, offset: pageSize * page});
};
<template name="messages">
<table>
<tbody>
{{#each_with_previous beingViewed}}
{{> row}}
{{/each_with_previous}}
</tbody>
</table>
</template>
<template name="row">
<tr>
<td>{{item.timestamp}}</td>
<td>{{item.name}}</td>
<td>{{item.message}}</td>
</tr>
</template>
@aaronj1335
Copy link
Copy Markdown
Author

i'm trying to iterate through the results of a collection.find() call in a template (like with {{#each}}), but i'm going to want to be able to check the previous row in the row template, so i'm trying to make this each_with_previous template helper work.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment