Class: Nanoc::Cachebuster::Html

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

Overview

The Html strategy looks for HTML-style attributes in the item source code, picking up the values of href and src attributes. This will typically cover links, stylesheets, images and javascripts.

Constant Summary collapse

REGEX =
/
  (href|src)        # Look for either an href="" or src="" attribute
  =                 # ...followed by an =
  ("|'|)            # Then either a single, double or no quote at all
  (                 # Capture the entire reference
    [^'"]+          # Anything but something that would close the attribute
                    # And then the extension:
    (\.(?:#{Nanoc::Cachebuster::FILETYPES_TO_FINGERPRINT.join('|')}))
  )
  \2                # Repeat the opening quote
/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, attribute, quote, filename, extension) ⇒ Object



154
155
156
# File 'lib/nanoc/cachebuster/strategy.rb', line 154

def apply(m, attribute, quote, filename, extension)
  %Q{#{attribute}=#{quote}#{output_filename(filename)}#{quote}}
end