Class: Nanoc3::Layout
- Inherits:
-
Object
- Object
- Nanoc3::Layout
- Defined in:
- lib/nanoc3/base/layout.rb
Overview
Represents a layout in a nanoc site. It has content, attributes, an identifier and a modification time (to speed up compilation).
Instance Attribute Summary (collapse)
-
- (Hash) attributes
readonly
This layout's attributes.
-
- (String) identifier
slash.
-
- (Time) mtime
readonly
The time when this layout was last modified.
-
- (String) raw_content
readonly
The raw content of this layout.
-
- (Nanoc3::Site) site
The site this layout belongs to.
Instance Method Summary (collapse)
-
- (Object) [](key)
Requests the attribute with the given key.
-
- (Layout) initialize(raw_content, attributes, identifier, params_or_mtime = nil)
constructor
Creates a new layout.
- - (Object) inspect
Constructor Details
- (Layout) initialize(raw_content, attributes, identifier, params_or_mtime = nil)
Creates a new layout.
layout, or the time when this layout was last modified (deprecated).
layout was last modified
38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/nanoc3/base/layout.rb', line 38 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.freeze end |
Instance Attribute Details
- (Hash) attributes (readonly)
This layout's attributes
16 17 18 |
# File 'lib/nanoc3/base/layout.rb', line 16 def attributes @attributes end |
- (String) identifier
slash
20 21 22 |
# File 'lib/nanoc3/base/layout.rb', line 20 def identifier @identifier end |
- (Time) mtime (readonly)
The time when this layout was last modified
23 24 25 |
# File 'lib/nanoc3/base/layout.rb', line 23 def mtime @mtime end |
- (String) raw_content (readonly)
The raw content of this layout
13 14 15 |
# File 'lib/nanoc3/base/layout.rb', line 13 def raw_content @raw_content end |
- (Nanoc3::Site) site
The site this layout belongs to
10 11 12 |
# File 'lib/nanoc3/base/layout.rb', line 10 def site @site end |
Instance Method Details
- (Object) [](key)
Requests the attribute with the given key.
59 60 61 |
# File 'lib/nanoc3/base/layout.rb', line 59 def [](key) @attributes[key] end |
- (Object) inspect
63 64 65 |
# File 'lib/nanoc3/base/layout.rb', line 63 def inspect "<#{self.class}:0x#{self.object_id.to_s(16)} identifier=#{self.identifier}>" end |