Class: Nanoc2::Filters::RelativizePathsInCSS

Inherits:
Nanoc2::Filter show all
Includes:
Helpers::LinkTo
Defined in:
lib/nanoc2/filters/relativize_paths_in_css.rb

Constant Summary

Constants inherited from Nanoc2::Filter

Nanoc2::Filter::EXTENSIONS_MAP

Constants inherited from Plugin

Plugin::MAP

Instance Method Summary collapse

Methods included from Helpers::LinkTo

#link_to, #link_to_unless_current, #relative_path_to

Methods included from Helpers::HTMLEscape

#html_escape

Methods inherited from Nanoc2::Filter

#assigns, #filename, #initialize

Methods inherited from Plugin

identifier, identifiers, named, register

Constructor Details

This class inherits a constructor from Nanoc2::Filter

Instance Method Details

#run(content) ⇒ Object



9
10
11
12
13
# File 'lib/nanoc2/filters/relativize_paths_in_css.rb', line 9

def run(content)
  content.gsub(/url\((['"]?)(\/.+?)\1\)/) do
    'url(' + $1 + relative_path_to($2) + $1 + ')'
  end
end