Module: Staticpress::Content::StaticContent

Included in:
Page, Page, Theme, Theme
Defined in:
lib/staticpress/content/static_content.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.supported_extensionsObject



26
27
28
# File 'lib/staticpress/content/static_content.rb', line 26

def self.supported_extensions
  Tilt.mappings.keys.reject { |mapping| mapping == '' }.map &:to_sym
end

Instance Method Details

#layoutObject

layout not needed for binary files



6
7
8
# File 'lib/staticpress/content/static_content.rb', line 6

def layout
  static? ? nil : super
end

#parse_slug(path, base_path) ⇒ Object



10
11
12
13
14
15
16
17
18
19
20
# File 'lib/staticpress/content/static_content.rb', line 10

def parse_slug(path, base_path)
  path_string = path.to_s

  clean = lambda { |str| str.sub(base_path.to_s, '').sub(/^\//, '') }

  if Staticpress::Content::StaticContent.supported_extensions.any? { |ext| path_string.end_with? ext.to_s }
    [ clean.call(extensionless_path(path).to_s), path.extname.sub(/^\./, '').to_sym ]
  else
    [ clean.call(path_string), nil ]
  end
end

#render_partial(locals = {}) ⇒ Object



22
23
24
# File 'lib/staticpress/content/static_content.rb', line 22

def render_partial(locals = {})
  static? ? template_path_content : super
end