Class: Sitepress::Extensions::PartialsRemover

Inherits:
Object
  • Object
show all
Defined in:
lib/sitepress/extensions/partials_remover.rb

Overview

Removes files beginning with “_” from the resource collection.

Constant Summary collapse

PARTIAL_PREFIX =

Partial rails prefix.

"_".freeze

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.partial?(path) ⇒ Boolean

Returns:

  • (Boolean)

14
15
16
# File 'lib/sitepress/extensions/partials_remover.rb', line 14

def self.partial?(path)
  File.basename(path).starts_with? PARTIAL_PREFIX
end

Instance Method Details

#process_resources(node) ⇒ Object


8
9
10
11
12
# File 'lib/sitepress/extensions/partials_remover.rb', line 8

def process_resources(node)
  node.flatten.each do |r|
    r.node.remove if self.class.partial? r.asset.path # Looks like a smiley face, doesn't it?
  end
end