Sunday 15 January 2012

haml - ruby - if string is not contained within an array -


I want to output only one anchor if the current_page is in the array then let me (.html and -nf.html) get. If this is not in the array then I will get many anchors because there are items in the array I

I am using.

- If page_f [[current_indix]]

    Edit:  

If you want your first search to be the only one, you can break each loop. But now it looks a bit weird because you are running on an array again and after breaking the first element, whatever it may be. Am I completely addressing your problem?

  option [: pre_flash] = ['string_one-nf', 'string_two-nf', 'string_three-nf'] Page_ Western [: pre_flash] .each Do | Every_string If current_page.include? Every_string% li% a {: href = & gt; "Page # {page_options [: current_index]} - nf.html" ,: class = & gt; "Next"} # this is the last anchor brake and% li% a {: href = & gt; "Page # {page_options [: current_index]} .HTML" ,: class = & gt; "Next"} # This is the last anchor brake end and  

No comments:

Post a Comment