module Parade::Renderers::InlineImages

This Renderer will inline the images into content output. Allowing you to create portable documents.

Public Class Methods

render(content,options = {}) click to toggle source
# File lib/parade/renderers/inline_images.rb, line 11
def self.render(content,options = {})

  content.gsub(/img src=["']\/?([^\/].*?)["']/) do |image_source|
    image_name = Regexp.last_match(1)

    base64_data = image_path_to_base64(image_name)

    if base64_data
      %{img src="#{base64_data}"}
    else
      image_source
    end
  end

end