0

Here is my hash

{ 'name1': 
   { display_name: 'xxxx',
     description: 'desc',
     value: '2345' },
  'name2': 
   { display_name: 'yyyy',
     description: 'desc',
     value: null } }

My mustache template

{{display_name}} : {{value}}

This obviously doesn't work. How do I refer to the display_name and value of each element in the object?

Gui Imamura
  • 536
  • 8
  • 25
user5095359
  • 47
  • 10
  • Possibly related to this: http://stackoverflow.com/questions/9058774/handlebars-mustache-is-there-a-built-in-way-to-loop-through-the-properties-of – lemieuxster Jul 08 '15 at 18:47

2 Answers2

0

You'll need to use a Mustache Section for the given key, e.g.

{{#name1}}
  {{display_name}}: {{value}}
{{/name1}}

More examples from the documentation. You can also try mustache online for a quick illustration.

myconode
  • 2,238
  • 23
  • 27
0

Either use the Mustache section, or specify what you're trying to view.

Mustache section:

{{#name1}}
  {{display_name}} : {{value}}
{{/name1}}

Sppecifying:

{{name1.display_name}} : {{name1.value}}

You can also loop through it if you want to, as mentioned by @lemieuxter

Community
  • 1
  • 1
Gui Imamura
  • 536
  • 8
  • 25