Module: FaqHelper

Defined in:
app/helpers/faq_helper.rb

Defined Under Namespace

Classes: Sanitizer

Instance Method Summary collapse

Instance Method Details

#faq_content_html(faq) ⇒ Object



20
21
22
# File 'app/helpers/faq_helper.rb', line 20

def faq_content_html(faq)
  RDiscount.new(render(:inline => faq.content)).to_html.html_safe
end

#faq_summary_html(faq) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
17
18
# File 'app/helpers/faq_helper.rb', line 6

def faq_summary_html(faq)
  if faq.summary.present?
     :p, faq.summary
  else
    reg = /<!--more-->/
    html_text = faq_content_html(faq)

    html = !((html_text =~ reg).nil?) ? html_text[0..(html_text =~ reg)-1] : html_text
    doc = Nokogiri::HTML.fragment(html)
    doc = doc.search('p').detect { |p| p.text.present? } if (html_text =~ reg).nil?
    doc.try(:to_html).try(:html_safe)
  end
end