nested content_tags escape inner html.. why?

前端 未结 3 1248
情书的邮戳
情书的邮戳 2021-02-04 15:36

So, if I loop through and create a collection of li/a tags, I get as expected.. an array of these tags:

(1..5).to_a.map do
  content_tag(:li) do
    link_to(\"bo         


        
3条回答
  •  清酒与你
    2021-02-04 16:26

    What happens if you use safe_join?

    content_tag(:ol) do
      safe_join (1..5).to_a.map {
          content_tag(:li) { link_to("boo", "www.boohoo.com") } 
        }, ''
    end
    

    Or just use raw?

    content_tag(ol) do
      1.upto(5) {
        raw content_tag(:li) { link_to 'boo', 'www.boohoo.com' }
        #  or maybe
        #    raw content_tag(:li) { raw link_to('boo', 'www.boohoo.com') } 
      }
    end
    

提交回复
热议问题