Module: Jekyll::SiteIgnoreLayout

Defined in:
lib/jekyll/site_ignore_layout.rb

Class Method Summary collapse

Class Method Details

.included(base) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/jekyll/site_ignore_layout.rb', line 5

def self.included(base)
  base.class_eval do
    # Determine if a layout is ignored and cache the result
    def ignored_layout?(layout)
      return false unless config['ignored_layouts']

      unless config['ignored_layouts'].is_a? Array
        raise Jekyll::Errors::InvalidConfigurationError, "`ignored_layouts` must be an Array"
      end

      @ignored_layout ||= {}

      # We could use ||= but it runs everytime when inclusion
      # returns false.
      if @ignored_layout.key? layout
        @ignored_layout[layout]
      else
        @ignored_layout[layout] = config['ignored_layouts'].include?(layout)
      end
    end
  end
end