Hey guys! I’m a bit fuzzy about spacebars data contexts and stuff… Can someone plz help out with this:
My tpl.jade:
.menu
+each city
.item(data-id='#{_id}') #{name} , #{parentRegion}
My .coffee:
tpl.helpers
city:-> Geo.find({type:'city'})
parentRegion: -> Geo.find({type:'region'})
My Geo collection:
{
"_id" : "RU-R001-C001",
"name" : "Moscow",
"type" : "city"
},
{
"_id" : "RU-R001",
"name" : "Moscow Region",
"type" : "region"
}
I want to have the following text in my .item
: 'Moscow, Moscow Region’
My logic was to get the _id
of the city, lookup its parent region (via 7 first chars of the _id
) and produce parent’s name. But I don’t actually know how to realize that logic.