slim template iniline ruby code -


i''m trying include ruby code in slim template, code want put in slim:

      - nav_links_group = nil       - if if_page_var('visible', :main_menu, :solutions)       -   nav_links_group = @nav_links["solutions"]       - elsif if_page_var('visible', :main_menu, :resources)       -   nav_links_group = @nav_links["resources"]       - elsif if_page_var('visible', :main_menu, :people)       -   nav_links_group = @nav_links["people"]       -end        - if nav_links_group       - current_index = nav_links_group.map{|e| e[0]}.index(request.original_url)         - if current_index == 0           span = sub_menu_link "#{nav_links_group[current_index + 1][0]}", "#{nav_links_group[current_index + 1][1]}"         - elsif current_index + 1 == nav_links_group.count           span = sub_menu_link "#{nav_links_group[current_index - 1][0]}", "#{nav_links_group[current_index - 1][1]}"         - elsif current_index > 0 && current_index + 1 != nav_links_group.count           span = sub_menu_link "#{nav_links_group[current_index - 1][0]}", "#{nav_links_group[current_index - 1][1]}"           span = sub_menu_link "#{nav_links_group[current_index + 1][0]}", "#{nav_links_group[current_index + 1][1]}"         - end       - end 

i got error: syntax error, unexpected keyword_elsif

any suggestions?

reviewing code, can issue :

  • slim doesn't use - end
  • your indentations messed
  • don't use space between tag , '=' (use span= sub_menu_link, not span = sub_menu_link)

here example

- nav_links_group = nil - if if_page_var('visible', :main_menu, :solutions)   - nav_links_group = @nav_links["solutions"] - elsif if_page_var('visible', :main_menu, :resources)   - nav_links_group = @nav_links["resources"] - elsif if_page_var('visible', :main_menu, :people)   - nav_links_group = @nav_links["people"]  - if nav_links_group   - current_index = nav_links_group.map{|e| e[0]}.index(request.original_url)   - if current_index == 0     span= sub_menu_link "#{nav_links_group[current_index + 1][0]}", "#{nav_links_group[current_index + 1][1]}"   - elsif current_index + 1 == nav_links_group.count     span= sub_menu_link "#{nav_links_group[current_index - 1][0]}", "#{nav_links_group[current_index - 1][1]}"     - elsif current_index > 0 && current_index + 1 != nav_links_group.count       span= sub_menu_link "#{nav_links_group[current_index - 1][0]}", "#{nav_links_group[current_index - 1][1]}"       span= sub_menu_link "#{nav_links_group[current_index + 1][0]}", "#{nav_links_group[current_index + 1][1]}" 

Comments

Popular posts from this blog

javascript - RequestAnimationFrame not working when exiting fullscreen switching space on Safari -

Python ctypes access violation with const pointer arguments -