0

Im trying to display mongodb data in a html page in a meteor application. Here, 'yyyy' is a dynamic property name in the mongodb document.

{{#with pullData}}
 <span>Root Url : {{xxxx.yyyy.zzzz}} </span>
{{/with}}

My mongodb document looks like this:

    { _id : '......',
      xxxx:{
       yyyy:{
       zzzz: 'sampleData'
    }}}

'yyyy' is dynamic -> can be different names of people(for example, John or Jane)

I tried using a helper to construct the "xxxx.John.zzzz" with the appropriate dynamic value and call the helper inside the handlebar but it returns it("xxxx.John.zzzz") as a string.

{{#with pullData}}
     <span>Root Url : {{helper}} </span>
    {{/with}}

Pls help ! Thank you ..

Keith Dawson
  • 1,475
  • 16
  • 27
zoro
  • 17
  • 5

1 Answers1

1

Have your helper return this.xxxx['yyyy'].zzzz;

Basically you need to use bracket notation instead of dot notation to access that sub-object using a variable name.

Community
  • 1
  • 1
Michel Floyd
  • 18,793
  • 4
  • 24
  • 39