Sha256: 0ea0ea9d3a6bdd69ef6b8f0827f723cce99cc3ac358390e484656e7b648a100c

Contents?: true

Size: 1.22 KB

Versions: 14

Compression:

Stored size: 1.22 KB

Contents

# frozen_string_literal: true

module Bridgetown
  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

      @base_dir = site.source
      @path = site.in_source_dir(base, name)
      @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

14 entries across 14 versions & 1 rubygems

Version Path
bridgetown-core-0.13.0 lib/bridgetown-core/layout.rb
bridgetown-core-0.12.1 lib/bridgetown-core/layout.rb
bridgetown-core-0.12.0 lib/bridgetown-core/layout.rb
bridgetown-core-0.11.2 lib/bridgetown-core/layout.rb
bridgetown-core-0.11.1 lib/bridgetown-core/layout.rb
bridgetown-core-0.11.0 lib/bridgetown-core/layout.rb
bridgetown-core-0.10.2 lib/bridgetown-core/layout.rb
bridgetown-core-0.10.1 lib/bridgetown-core/layout.rb
bridgetown-core-0.10.0 lib/bridgetown-core/layout.rb
bridgetown-core-0.9.0 lib/bridgetown-core/layout.rb
bridgetown-core-0.8.1 lib/bridgetown-core/layout.rb
bridgetown-core-0.8.0 lib/bridgetown-core/layout.rb
bridgetown-core-0.7.2 lib/bridgetown-core/layout.rb
bridgetown-core-0.7.1 lib/bridgetown-core/layout.rb