Class: Slimmer::Processors::BodyClassCopier

Inherits:
Object
  • Object
show all
Defined in:
lib/slimmer/processors/body_class_copier.rb

Instance Method Summary collapse

Instance Method Details

#filter(src, dest) ⇒ Object



3
4
5
6
7
8
9
10
11
# File 'lib/slimmer/processors/body_class_copier.rb', line 3

def filter(src, dest)
  src_body_tag = src.at_css("body")
  dest_body_tag = dest.at_css("body")
  if src_body_tag.has_attribute?("class")
    combinded_classes = dest_body_tag.attr("class").to_s.split(/ +/)
    combinded_classes << src_body_tag.attr("class").to_s.split(/ +/)
    dest_body_tag.set_attribute("class", combinded_classes.join(" "))
  end
end