SORU
14 EKİM 2010, PERŞEMBE


Don'raylar üzerinde yakut t escape html

3 her şeyi kaçmak gibi görünüyor raylar, html dahil. Raw kullanarak denedim() ama yine de html kaçar. Geçici bir çözüm var mı? Bu ben kullanıyorum Yardımcısı benim (/application_helper/yardımcıları.rb):

module ApplicationHelper
  def good_time(status = true)
    res = ""
    if status == true
      res << "Status is true, with a long message attached..."
    else
      res << "Status is false, with another long message"
    end
  end
end

Benim görüşüme yardımcı bu kodu kullanarak sesleniyorum:

<%= raw(good_time(true)) %>

CEVAP
14 EKİM 2010, PERŞEMBE


Bu gibi .html_safe kullanabilirsiniz:

def good_time(status = true)
  if status
    "Status is true, with a long message attached...".html_safe
  else
    "Status is false, with another long message".html_safe
  end
end

<%= good_time(true) %>

Bunu Paylaş:
  • Google+
  • E-Posta
Etiketler:

YORUMLAR

SPONSOR VİDEO

Rastgele Yazarlar

  • Official Android Tips

    Official And

    23 EYLÜL 2009
  • StalkerJS

    StalkerJS

    15 HAZİRAN 2010
  • theavettbrothers

    theavettbrot

    9 ŞUBAT 2007