Sha256: 8bd64ad9d718ba9092a94aa92de24f06af073ad4e6be2a9445aed9e8e63fb431

Contents?: true

Size: 826 Bytes

Versions: 1

Compression:

Stored size: 826 Bytes

Contents

module MongoidForums
  module FormattingHelper
    # override with desired markup formatter, e.g. textile or markdown
    def as_formatted_html(text)
      if MongoidForums.formatter
        MongoidForums.formatter.format(as_sanitized_text(text))
      else
        MongoidForums::Sanitizer.sanitize(text).html_safe
      end
    end

    def as_quoted_text(text)
      if MongoidForums.formatter && Forem.formatter.respond_to?(:blockquote)
        MongoidForums.formatter.blockquote(as_sanitized_text(text)).html_safe
      else
         "<blockquote>#{(h(text))}</blockquote>\n\n".html_safe
      end
    end

    def as_sanitized_text(text)
      if MongoidForums.formatter.respond_to?(:sanitize)
        MongoidForums.formatter.sanitize(text)
      else
        Forem::Sanitizer.sanitize(text)
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
mongoid-forums-0.0.1 app/helpers/mongoid_forums/formatting_helper.rb