Reputation: 1490
I have the following template:
<body>
<table border="1px">
{{> test}}
<table>
</body>
<template name="test">
{{#each items}}
<tr>
{{> test2}}
</tr>
{{/each}}
</template>
<template name="test2">
<td>{{name}}</td><td>{{lastruntime}}</td><td>{{result}}</td><td>{{blaat}}</td>
</template>
And the following client-side code:
ScheduledTasks = new Meteor.Collection("scheduledTasks");
if (Meteor.isClient) {
Template.test.items = function () {
return ScheduledTasks.find({});
}
};
Now {{blaat}} is not part of the document, but needs to be filled with data based on the data in the individual row. I tried a lot, but cannot find out how to access/fill the {{blaat}} tag. Anyone?
Upvotes: 0
Views: 93
Reputation: 64342
You can use map to modify each document by adding a blaat
property. Then you can return the array of modified documents, instead of returning a cursor. For example:
Template.test.items = function() {
return ScheduledTasks.find().map(function(item) {
item.blaat = item.name + item.result;
return item;
});
};
The blaat
property will then be available to your template, just like name
and result
.
Alternatively, if you thought the blaat
property should always be present whenever you retrieve a scheduled task, then you could consider adding a transofrm to the collection.
Upvotes: 2