Class: Slimmer::Processors::ConditionalCommentMover

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

Instance Method Summary collapse

Instance Method Details

#filter(src, dest) ⇒ Object



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

def filter(src, dest)
  src.xpath("//comment()").each do |comment|
    if match_conditional_comments(comment)
      dest.at_xpath("/html/head") << comment
    end
  end
end

#match_conditional_comments(str) ⇒ Object



11
12
13
# File 'lib/slimmer/processors/conditional_comment_mover.rb', line 11

def match_conditional_comments(str)
  str.to_s =~ /<!--\[[A-Za-z0-9 ]+\]>(.*)<!\[endif\]-->/m
end