Class: Slimmer::Processors::HeaderContextInserter

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

Instance Method Summary collapse

Constructor Details

#initialize(path = ".header-context") ⇒ HeaderContextInserter

Returns a new instance of HeaderContextInserter.



3
4
5
# File 'lib/slimmer/processors/header_context_inserter.rb', line 3

def initialize(path = ".header-context")
  @path = path
end

Instance Method Details

#filter(src, dest) ⇒ Object



7
8
9
10
11
12
# File 'lib/slimmer/processors/header_context_inserter.rb', line 7

def filter(src, dest)
  if dest.at_css(@path) && (replacement = src.at_css(@path))
    header_context = src.fragment(replacement)
    dest.at_css(@path).replace(header_context)
  end
end