Class: Nanoc::Cachebuster::Css

Inherits:
Strategy
  • Object
show all
Defined in:
lib/nanoc/cachebuster/strategy.rb

Overview

The Css strategy looks for CSS-style external references that use the url() syntax. This will typically cover any @import statements and references to images.

Constant Summary collapse

REGEX =
/
  url\(          # Start with the literal url(
  ('|"|)         # Then either a single, double or no quote at all
  (
    ([^'")]+)    # The file basename, and below the extension
    \.(#{Nanoc::Cachebuster::FILETYPES_TO_FINGERPRINT.join('|')})
  )
  \1             # Repeat the same quote as at the start
  \)             # And cose the url()
/ix

Instance Attribute Summary

Attributes inherited from Strategy

#current_item, #site

Instance Method Summary collapse

Methods inherited from Strategy

for, inherited, #initialize

Constructor Details

This class inherits a constructor from Nanoc::Cachebuster::Strategy

Instance Method Details

#apply(m, quote, filename, basename, extension) ⇒ Object



133
134
135
# File 'lib/nanoc/cachebuster/strategy.rb', line 133

def apply(m, quote, filename, basename, extension)
  m.sub(filename, output_filename(filename).to_s)
end