Sha256: 335ecf0fc25a431b09e5155888a468bf601a4f964b3994a5a7d4bd4b7c86ffb2

Contents?: true

Size: 1.38 KB

Versions: 34

Compression:

Stored size: 1.38 KB

Contents

# frozen_string_literal: true

module Jekyll
  class Layout
    include Convertible

    # Gets the Site object.
    attr_reader :site

    # Gets the name of this layout.
    attr_reader :name

    # Gets the path to this layout.
    attr_reader :path

    # Gets the path to this layout relative to its base
    attr_reader :relative_path

    # Gets/Sets the extension of this layout.
    attr_accessor :ext

    # Gets/Sets the Hash that holds the metadata for this layout.
    attr_accessor :data

    # Gets/Sets the content of this layout.
    attr_accessor :content

    # Initialize a new Layout.
    #
    # site - The Site.
    # base - The String path to the source.
    # name - The String filename of the post file.
    def initialize(site, base, name)
      @site = site
      @base = base
      @name = name

      if site.theme && site.theme.layouts_path.eql?(base)
        @base_dir = site.theme.root
        @path = site.in_theme_dir(base, name)
      else
        @base_dir = site.source
        @path = site.in_source_dir(base, name)
      end
      @relative_path = @path.sub(@base_dir, "")

      self.data = {}

      process(name)
      read_yaml(base, name)
    end

    # Extract information from the layout filename.
    #
    # name - The String filename of the layout file.
    #
    # Returns nothing.
    def process(name)
      self.ext = File.extname(name)
    end
  end
end

Version data entries

34 entries across 34 versions & 2 rubygems

Version Path
jekyll-3.10.0 lib/jekyll/layout.rb
jekyll-3.9.5 lib/jekyll/layout.rb
jekyll-3.9.4 lib/jekyll/layout.rb
jekyll-3.9.3 lib/jekyll/layout.rb
jekyll-3.9.2 lib/jekyll/layout.rb
jekyll-3.9.1 lib/jekyll/layout.rb
jekyll-3.9.0 lib/jekyll/layout.rb
jekyll-4.1.1 lib/jekyll/layout.rb
jekyll-4.1.0 lib/jekyll/layout.rb
jekyll-4.0.1 lib/jekyll/layout.rb
jekyll-3.8.7 lib/jekyll/layout.rb
jekyll-4.0.0 lib/jekyll/layout.rb
jekyll-4.0.0.pre.beta1 lib/jekyll/layout.rb
jekyll-3.8.6 lib/jekyll/layout.rb
jekyll-4.0.0.pre.alpha1 lib/jekyll/layout.rb
jekyll-3.8.5 lib/jekyll/layout.rb
jekyll-3.6.3 lib/jekyll/layout.rb
jekyll-3.8.4 lib/jekyll/layout.rb
jekyll-3.7.4 lib/jekyll/layout.rb
jekyll-3.8.3 lib/jekyll/layout.rb