Class: Usmu::Template::Page

Inherits:
Layout show all
Defined in:
lib/usmu/template/page.rb

Overview

Represents a page in the source directory of the website.

Instance Attribute Summary collapse

Attributes inherited from Layout

#helpers, #input_path, #metadata, #output_extension, #output_filename, #parent, #provider_name, #template_class, #type

Attributes inherited from StaticFile

#input_path, #name, #output_filename

Instance Method Summary collapse

Methods inherited from Layout

#[], #[]=, #add_template_defaults, find_layout, #get_variables, is_valid_file?, #render, search_layout

Methods inherited from StaticFile

#render

Constructor Details

#initialize(configuration, name, metadata, type = nil, content = nil) ⇒ Page

Returns a new instance of Page.

Parameters:

  • configuration (Usmu::Configuration)

    The configuration for the website we're generating.

  • name (String)

    The name of the file in the source directory.

  • metadata (Hash)

    The metadata for the file.

  • type (String) (defaults to: nil)

    The type of template to use with the file. Used for testing purposes.

  • content (String) (defaults to: nil)

    The content of the file. Used for testing purposes.



13
14
15
16
17
18
19
20
21
22
# File 'lib/usmu/template/page.rb', line 13

def initialize(configuration, name, , type = nil, content = nil)
  super(configuration, name, , type, content)

  current_parent = parent
  until current_parent.nil?
    @log.debug("Injecting page #{name} into #{current_parent.name}")
    current_parent['page'] = self
    current_parent = current_parent.parent
  end
end

Instance Attribute Details

#content_pathstring (readonly, protected)

Returns the base path to the files used by this class.

This folder should be the parent folder for the file named by the name attribute.

Returns:

  • (string)

    the base path to the files used by this class.

See Also:



34
35
36
# File 'lib/usmu/template/page.rb', line 34

def content_path
  @configuration.source_path
end