Parent

Methods

Class/Module Index [+]

Quicksearch

Nanoc3::Layout

Represents a layout in a nanoc site. It has content, attributes, an identifier and a modification time (to speed up compilation).

Attributes

attributes[R]

@return [Hash] This layout’s attributes

identifier[RW]

@return [String] This layout’s identifier, starting and ending with a slash

mtime[R]

@return [Time] The time when this layout was last modified

raw_content[R]

@return [String] The raw content of this layout

site[RW]

@return [Nanoc3::Site] The site this layout belongs to

Public Class Methods

new(raw_content, attributes, identifier, params_or_mtime=nil) click to toggle source

Creates a new layout.

@param [String] raw_content The raw content of this layout.

@param [Hash] attributes A hash containing this layout’s attributes.

@param [String] identifier This layout’s identifier.

@param [Time, Hash, nil] params_or_mtime Extra parameters for the layout, or the time when this layout was last modified (deprecated).

@option params_or_mtime [Time, nil] :mtime (nil) The time when this layout was last modified

# File lib/nanoc3/base/layout.rb, line 37
def initialize(raw_content, attributes, identifier, params_or_mtime=nil)
  # Get params and mtime
  # TODO [in nanoc 4.0] clean this up
  if params_or_mtime.nil? || params_or_mtime.is_a?(Time)
    params = {}
    @mtime = params_or_mtime
  elsif params_or_mtime.is_a?(Hash)
    params = params_or_mtime
    @mtime = params[:mtime]
  end

  @raw_content  = raw_content
  @attributes   = attributes.symbolize_keys
  @identifier   = identifier.cleaned_identifier
end

Public Instance Methods

[](key) click to toggle source

Requests the attribute with the given key.

@param [Symbol] key The name of the attribute to fetch.

@return [Object] The value of the requested attribute.

# File lib/nanoc3/base/layout.rb, line 58
def [](key)
  @attributes[key]
end
inspect() click to toggle source
# File lib/nanoc3/base/layout.rb, line 62
def inspect
  "<#{self.class}:0x#{self.object_id.to_s(16)} identifier=#{self.identifier}>"
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.