Reputation: 48453
I am getting from controller data in global variable @controller_data
which contains array.
I am also using Highcharts, where is used following procedure for rendering data in charts:
data = [{
y: 55.11,
color: colors[0]
}, {
y: 21.63,
color: colors[1]
}, {
y: 11.94,
color: colors[2]
}, {
y: 7.15,
color: colors[3]
}, {
y: 2.14,
color: colors[4]
}];
I am using HAML template system. How to fill out this Javascript array with data from controller?
Thanks
Upvotes: 0
Views: 580
Reputation: 303271
Assuming that @controller_data
is just a simple array of hashes, suitable for passing directly to JavaScript:
:javascript
data = #{@controller_data.to_json};
Haml allows you to do string interpolation inside of content, including JavaScript Filters.
Upvotes: 1