How do I run a long block of ruby code in a HAML file, including an array? -


i have bit of ruby outputs correctly .rb file. however, want include equivalent code in haml file, , can't output correctly. i've tried reformat in various ways, haven't been able figure out, nor find i'm looking in question.

i'm generating repeated div blocks, using elements stored in array of arrays. there groups of 3 .class objects want group under .row. i've got make bunch of these, want automate if possible. right can run ruby code in sublime text, , copy+paste formatted haml haml page... seems should able in-line!

here's ruby code:

gfys = [   [ #row 1     {"title"=>"move", "id"=>"#gfy0a", "desc"=>"use either analog stick or directional buttons."},     {"title"=>"shoot", "id"=>"#gfy0b", "desc"=>"press button; pull trigger."},     {"title"=>"push", "id"=>"#gfy0c", "desc"=>"projectiles displace ball on impact."}   ],   [ #row 2     {"title"=>"aim", "id"=>"#gfy1a", "desc"=>"projectiles triangular. balls circular."},     {"title"=>"launch", "id"=>"#gfy1b", "desc"=>"shoot while moving faster projectiles."},     {"title"=>"score", "id"=>"#gfy1c", "desc"=>"push ball opposing goal earn point."}   ] ]  gfys.each |group|   puts "// row #{gfys.index(group)}"   puts ".row"   group.each |gfy|     puts "\t.class     .class2       %h2         #{gfy["title"]}       #{gfy["id"]}.class       %p         #{gfy["desc"]}"   end end 

this outputs correctly haml code:

// row 0 .row   .class     .class2       %h2         move       #gfy0a.class       %p         use either analog stick or directional buttons.   .class     .class2       %h2         shoot       #gfy0b.class       %p         press button; pull trigger.   .class     .class2       %h2         push       #gfy0c.class       %p         projectiles displace ball on impact. // row 1 .row   .class     .class2       %h2         aim       #gfy1a.class       %p         projectiles triangular. balls circular.   .class     .class2       %h2         launch       #gfy1b.class       %p         shoot while moving faster projectiles.   .class     .class2       %h2         score       #gfy1c.class       %p         push ball opposing goal earn point. 

now, running code under :ruby filter in haml file doesn't work me. seems print whole array page, , else gets goofy. taking out end tags, , accounting haml's attempts "simplify" code don't work. putting - or = characters appropriate before code hasn't worked me.

i know situation complicated formatting in array, collapsing array single line didn't help, either.

finally, i'm pre-compiling before uploading page, using hammer.app, if matters.

is i'm trying crazy? or missing? appreciate help!


Comments

Popular posts from this blog

google chrome - Developer tools - How to inspect the elements which are added momentarily (by JQuery)? -

angularjs - Showing an empty as first option in select tag -

php - Cloud9 cloud IDE and CakePHP -