mongodb - Use #each with argument in Meteor -


i'm new meteor framework , i'm trying show data meteor + mongo + spacebars. problem might need use 1 argument spacebar, #each, , not allow it.

my code:

$ file.js

  template.home.helpers({       places: function() {           return places.find();       }   });    template.content.helpers({     images: function() {         return images.find({});      }   });  

$ file.html

<template name="home">         {{#each places}}         {{>content}}     {{/each}} </template>  <template name="content">     <li>{{name}} - {{date}}</li>     {{#each images}}         <img src="{{this.url}}">         {{/each}} </template> 

what want - , didn't work - use argument in template.content.helper function, below:

  template.content.helpers({     images: function(arg) {         return images.find({place: arg});      }   });  

and in html file be

<template name="content">     <li>{{name}} - {{date}}</li>     {{#each images {{name}} }}         <img src="{{this.url}}">         {{/each}} </template> 

do guys have idea how show information correctly? don't want show information (images) each place. want show images correspondent place only...

thanks in advance, marcus

as helper's implementation can access current data context this, need not pass {{name}} argument. in stead, access {{name}} in helper this.name .

jade

<template name="content">   <li>{{name}} - {{date}}</li>   {{#each images}}     <img src="{{this.url}}">       {{/each}} </template> 

js

template.content.helpers({   images: function() {     place = this.name;     return images.find({place: place});   } });  

Comments

Popular posts from this blog

dns - How To Use Custom Nameserver On Free Cloudflare? -

python - Pygame screen.blit not working -

c# - Web API response xml language -