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
  • 556
  • 9
  • 26
user5095359
  • 47
  • 1
  • 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,518
  • 1
  • 26
  • 28
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
  • 556
  • 9
  • 26