class Decidim::ContentRenderers::BaseRenderer
Abstract base class for content renderers, so they have the same contract
@example How to use a content renderer class
renderer = Decidim::ContentRenderers::CustomRenderer.new(content) parser.render # returns the content formatted
@abstract Subclass and override {#render} to implement a content renderer
Attributes
content[R]
@return [String] the content to be formatted
Public Class Methods
new(content)
click to toggle source
Gets initialized with the `content` to format
@param content [String] content to be formatted
# File lib/decidim/content_renderers/base_renderer.rb, line 19 def initialize(content) @content = content || "" end
Public Instance Methods
render(_options = nil)
click to toggle source
Format the content and return it ready to display
@example Implementation to display prohibited words
def render content.gsub(/\~\~(.*?)\~\~/, '<del>\1</del>') end
@abstract Subclass is expected to implement it @return [String] the content processed and ready to display
# File lib/decidim/content_renderers/base_renderer.rb, line 32 def render(_options = nil) content end