class Mbrao::RenderingEngines::HtmlPipeline

A renders which use the [html-pipeline](github.com/jch/html-pipeline) gem.

@attribute default_pipeline

@return [Array] The default pipeline to use. It should be an array of pairs of `Symbol`, which the first element is the filter (in underscored version
  and without the filter suffix) and the second is a shortcut to disable the pipeline via options.
  You can also specify a single element to disable shortcuts.

@attribute default_options

@return [Hash] The default options for the renderer.

Attributes

default_options[RW]
default_pipeline[RW]

Public Instance Methods

default_options=(value) click to toggle source

Sets the default options.

@param value [Object] The new default options.

# File lib/mbrao/rendering_engines/html_pipeline.rb, line 64
def default_options=(value)
  @default_options = value.ensure_hash
end
default_pipeline=(value) click to toggle source

Sets the default pipeline.

@return [Array] The default pipeline.

# File lib/mbrao/rendering_engines/html_pipeline.rb, line 50
def default_pipeline=(value)
  @default_pipeline = value.ensure_array { |v| v.ensure_array(no_duplicates: true, compact: true, flatten: true) { |p| p.ensure_string.to_sym } }
end
render(content, options = {}, context = {}) click to toggle source

Renders a content.

@param content [Content|String] The content to parse. @param options [Hash] A list of options for renderer. @param context [Hash] A context for rendering.

# File lib/mbrao/rendering_engines/html_pipeline.rb, line 27
def render(content, options = {}, context = {})
  options = sanitize_options(options)
  context = context.ensure_hash(accesses: :symbols)

  begin
    create_pipeline(options, context).call(get_body(content, options))[:output].to_s
  rescue Mbrao::Exceptions::UnavailableLocalization => le
    raise le
  rescue => e
    raise ::Mbrao::Exceptions::Rendering, e.to_s
  end
end