Sha256: b9eecfd78704e3aacdafbfdf23dc760086ccae9a539dc3c2418b2ce0bad48d0a
Contents?: true
Size: 973 Bytes
Versions: 2
Compression:
Stored size: 973 Bytes
Contents
module BootstrapEmail module Component class HeadStyle < Base def build doc.at_css('head').add_child(bootstrap_email_head) end private def bootstrap_email_head html_string = <<-INLINE <style type="text/css"> #{purged_css_from_head} </style> INLINE html_string end def purged_css_from_head default, custom = BootstrapEmail::SassCache.compile('bootstrap-head').split('/*! allow_purge_after */') # get each CSS declaration custom.scan(/\w*\.[\w\-]*[\s\S\n]+?(?=})}{1}/).each do |group| # get the first class for each comma separated CSS declaration exist = group.scan(/(\.[\w\-]*).*?((,+?)|{+?)/).map(&:first).uniq.any? do |selector| !doc.at_css(selector).nil? end custom.sub!(group, '') unless exist end (default + custom).gsub(/\n\s*\n+/, "\n") end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
bootstrap-email-1.0.0.alpha2.1 | lib/bootstrap-email/components/head_style.rb |
bootstrap-email-1.0.0.alpha2 | lib/bootstrap-email/components/head_style.rb |