Module: MongoidForums::FormattingHelper
- Included in:
- ApplicationHelper
- Defined in:
- app/helpers/mongoid_forums/formatting_helper.rb
Instance Method Summary collapse
-
#as_formatted_html(text) ⇒ Object
override with desired markup formatter, e.g.
- #as_quoted_text(text) ⇒ Object
- #as_sanitized_text(text) ⇒ Object
Instance Method Details
#as_formatted_html(text) ⇒ Object
override with desired markup formatter, e.g. textile or markdown
4 5 6 7 8 9 10 |
# File 'app/helpers/mongoid_forums/formatting_helper.rb', line 4 def as_formatted_html(text) if MongoidForums.formatter MongoidForums.formatter.format(as_sanitized_text(text)) else MongoidForums::Sanitizer.sanitize(text).html_safe end end |
#as_quoted_text(text) ⇒ Object
12 13 14 15 16 17 18 |
# File 'app/helpers/mongoid_forums/formatting_helper.rb', line 12 def as_quoted_text(text) if MongoidForums.formatter && MongoidForums.formatter.respond_to?(:blockquote) MongoidForums.formatter.blockquote(as_sanitized_text(text)).html_safe else "<blockquote>#{(h(text))}</blockquote>\n\n".html_safe end end |
#as_sanitized_text(text) ⇒ Object
20 21 22 23 24 25 26 |
# File 'app/helpers/mongoid_forums/formatting_helper.rb', line 20 def as_sanitized_text(text) if MongoidForums.formatter.respond_to?(:sanitize) MongoidForums.formatter.sanitize(text) else MongoidForums::Sanitizer.sanitize(text) end end |