2016-05-15 39 views

回答

0

那麼在js helper中做什麼呢?我是這樣做的。

Template.foo.helpers({ 

stuffWithAds : function(){ 

    col = GivenCollection.find().fetch(); 
    toTemplate = []; 

    for(i=0; i<col.length; i++){ 

     toTemplate.push(col[i]); 

     if (i % 2 != 0){ 

     toTemplate.push('whatever you want to insert'); 

     } 

    } 

    return toTemplate; } 

}); 

這插入任何你想要的2個元素後。