user1804020
user1804020

Reputation: 79

Iterate based on number provided in json

I'm getting a number back from json that represents the number of divs I need to create in my template. Is there a way to iterate and create the elements in the template based on this number using dust?

Upvotes: 0

Views: 127

Answers (2)

Rajkamal Subramanian
Rajkamal Subramanian

Reputation: 6944

Please have a look at http://jsfiddle.net/yXx5L/2/.

real_no 

is the number of times the template would be iterated.

based_on_number 

is a helper method that iterates the template for real_no times.

Upvotes: 0

smfoote
smfoote

Reputation: 5609

That's not possible. Dust only iterates over arrays. So, you could pass an array of the length you need.

Upvotes: 1

Related Questions