Reputation: 19896
I have a JSON to declare in :javascript
and I am not familiar with Ruby. The JSON is below:
:javascript
var collections = {
feed: [{'label': 'All', 'url': 'All', 'isSelected': false}]
};
But I want the part below in feed
variable to repeat 20 times:
{'label': 'All', 'url': 'All', 'isSelected': true}
How do I do that using Ruby in Haml?
Thanks.
Upvotes: 0
Views: 435
Reputation: 56
One way:
:javascript
var collections = {
feed: [<%="{'label': 'All', 'url': 'All', 'isSelected': false}" * 20 %>]
};
Another way:
:javascript
var colections = {
<%=(["feed: {'label': 'All', 'url': 'All', 'isSelected': false}"] * 20).join(',')%>
}
Upvotes: 1