class Parade::CSSTemplateGenerator
Generate inline CSS assets. Using CssParser it is able to traverse imports to ensure all CSS is inlined within the document.
Also embeds all images contained within the CSS into the inlined CSS.
Public Instance Methods
content()
click to toggle source
# File lib/parade/helpers/template_generator.rb, line 93 def content content_filepath = File.exists?(filepath) ? filepath : File.join(File.dirname(__FILE__), "..", "..", "public", "css", filepath) parser = CssParser::Parser.new parser.load_file!(content_filepath) css_contents = parser.to_s css_contents.gsub(/url\([\s"']*([^\)"'\s]*)[\s"']*\)/m) do |image_uri| image_name = Regexp.last_match(1) image_path = File.join File.dirname(content_filepath), image_name base64_data = image_path_to_base64(image_path) "url(#{base64_data})" end end
erb_template_file()
click to toggle source
# File lib/parade/helpers/template_generator.rb, line 109 def erb_template_file File.join File.dirname(__FILE__), "..", "..", "views", "inline_css.erb" end