Class: Thredded::ContentFormatter
- Inherits:
-
Object
- Object
- Thredded::ContentFormatter
- Defined in:
- lib/thredded/content_formatter.rb
Overview
Generates HTML from content source.
Instance Method Summary collapse
-
#format_content(content) ⇒ String
Formatted and sanitized html-safe content.
-
#initialize(view_context, pipeline_options = {}) ⇒ ContentFormatter
constructor
A new instance of ContentFormatter.
Constructor Details
#initialize(view_context, pipeline_options = {}) ⇒ ContentFormatter
Returns a new instance of ContentFormatter.
57 58 59 60 |
# File 'lib/thredded/content_formatter.rb', line 57 def initialize(view_context, = {}) @view_context = view_context @pipeline_options = end |
Instance Method Details
#format_content(content) ⇒ String
Returns formatted and sanitized html-safe content.
64 65 66 67 68 69 70 |
# File 'lib/thredded/content_formatter.rb', line 64 def format_content(content) pipeline = HTML::Pipeline.new(content_pipeline_filters, .merge(@pipeline_options)) result = pipeline.call(content, view_context: @view_context) # rubocop:disable Rails/OutputSafety result[:output].to_s.html_safe # rubocop:enable Rails/OutputSafety end |