Sha256: 79debf7f37faeec7606671dba20bfc5f3292bd6067daae678c1883fc25ddd216
Contents?: true
Size: 945 Bytes
Versions: 2
Compression:
Stored size: 945 Bytes
Contents
require 'open-uri' require 'rubygems' require 'nokogiri' require 'css_inliner/version' require 'css_inliner/csspool' require 'css_inliner/inliner' module CSSInliner class << self # @param [Nokogiri::XML::Document, String] html # @param [String] basedir Base directory or URI to traverse relative URI for images # @param [String] element Element name to be returned. # Returns whole document when nil # @param [String] format Format to output, html or xhtml # @return [String] HTML source def process(html, basedir = '.', element = nil, format = 'html') doc = html.instance_of?(Nokogiri::XML::Document) ? html : Nokogiri.XML(html) doc = Inliner.new(doc, basedir).inline doc = doc.css(element)[0] if element case format when 'xhtml' doc.to_xhtml when 'html' doc.to_html when 'xml' doc.to_xml else doc.to_s end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
css_inliner-0.3.0 | lib/css_inliner.rb |
css_inliner-0.2.1 | lib/css_inliner.rb |