5

i have a json object as

[ "id", "birthday", "companymsgsthisperiod", "companythisperiodend", "cust_attr_boolean", "subscribed", "testgroup", "usermsgsthisperiod", "userthisperiodend" ]

now i would like to add this type of json object using handlebar into a file as

<div>/*json*/</div>

Can anyone help me to get through it?

1
  • 1
    That's just a plain JS array of strings. Not JSON. Commented Feb 21, 2013 at 11:03

2 Answers 2

7

What you have there is an array. I guess from the documentation that you can use the each block helper

<div>
  {{#each dataArray}}
  <div>{{this}}</div>
  {{/each}}
</div>
Sign up to request clarification or add additional context in comments.

2 Comments

I have tried using each block but its not working it is giving depth error.
Did you happen to get a solution for this? I am also trying to print a n array of strings in handlebars. Thank you.
-1

Finally it may satisfy your need.

tryhandlebarsjs.com - screenshot

7 Comments

Is not {{#data}} as {{#each data}}
Do you have any documentation link to verify ? I just tried in tryhandlebarsjs.com and its not working..
Don't take me wrong I am just verifying your answer to learn myself.
Thats pointing to mustache.js thats different one. but question is tagged with handlebars.js, in handlebars your synax is wrong. it will not work.
{{.}} this is just printing the array. To iterate you need to use {{#each. In stack overflow, answer with link alone is not encouraged.
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.