Sha256: fc1aa5c92298cc0831ab677c250dfb837469653da022d9974bb143b41c606589

Contents?: true

Size: 1.25 KB

Versions: 16

Compression:

Stored size: 1.25 KB

Contents

module Jekyll

  class Layout
    include Convertible
    
    attr_accessor :ext
    attr_accessor :data, :content
    
    # Initialize a new Layout.
    #   +base+ is the String path to the <source>
    #   +name+ is the String filename of the post file
    #
    # Returns <Page>
    def initialize(base, name)
      @base = base
      @name = name
      
      self.data = {}
      
      self.process(name)
      self.read_yaml(base, name)
    end
    
    # Extract information from the layout filename
    #   +name+ is the String filename of the layout file
    #
    # Returns nothing
    def process(name)
      self.ext = File.extname(name)
    end
    
    # Add any necessary layouts to this post
    #   +layouts+ is a Hash of {"name" => "layout"}
    #   +site_payload+ is the site payload hash
    #
    # Returns nothing
    def add_layout(layouts, site_payload)
      payload = {"page" => self.data}.merge(site_payload)
      self.content = Liquid::Template.parse(self.content).render(payload, [Jekyll::Filters])
      
      layout = layouts[self.data["layout"]] || self.content
      payload = {"content" => self.content, "page" => self.data}
      
      self.content = Liquid::Template.parse(layout).render(payload, [Jekyll::Filters])
    end
  end

end

Version data entries

16 entries across 16 versions & 4 rubygems

Version Path
ddemaree-jekyll-0.2.1 lib/jekyll/layout.rb
gabrielg-jekyll-0.2.2 lib/jekyll/layout.rb
mojombo-jekyll-0.1.1 lib/jekyll/layout.rb
mojombo-jekyll-0.1.2 lib/jekyll/layout.rb
mojombo-jekyll-0.1.3 lib/jekyll/layout.rb
mojombo-jekyll-0.1.4 lib/jekyll/layout.rb
mojombo-jekyll-0.1.5 lib/jekyll/layout.rb
mojombo-jekyll-0.1.6 lib/jekyll/layout.rb
mojombo-jekyll-0.2.0 lib/jekyll/layout.rb
jekyll-0.1.3 lib/jekyll/layout.rb
jekyll-0.1.2 lib/jekyll/layout.rb
jekyll-0.1.5 lib/jekyll/layout.rb
jekyll-0.1.4 lib/jekyll/layout.rb
jekyll-0.2.1 lib/jekyll/layout.rb
jekyll-0.2.0 lib/jekyll/layout.rb
jekyll-0.1.6 lib/jekyll/layout.rb