Class: Usmu::Template::Include
- Inherits:
-
Layout
- Object
- StaticFile
- Layout
- Usmu::Template::Include
- Defined in:
- lib/usmu/template/include.rb
Overview
Represents a page in the source directory of the website.
Instance Attribute Summary collapse
-
#arguments ⇒ Hash
The arguments associated with this include.
-
#content_path ⇒ string
readonly
protected
Returns the base path to the files used by this class.
-
#metadata ⇒ Hash
readonly
Returns the metadata associated with this layout.
Attributes inherited from Layout
#helpers, #input_path, #output_extension, #output_filename, #parent, #provider_name, #template_class, #type
Attributes inherited from StaticFile
#input_path, #mtime, #name, #output_filename
Class Method Summary collapse
-
.find_include(configuration, name) ⇒ Usmu::Layout
Static method to create an include for a given configuration by it's name if it exists.
Instance Method Summary collapse
-
#get_variables(variables) ⇒ Hash
private
Utility function which collates variables to pass to the template engine.
-
#layout_metadata ⇒ void
private
Preserved version of the layout metadata logic.
Methods inherited from Layout
#[]=, #add_template_defaults, find_layout, #initialize, is_valid_file?, #render, #render_content, search_layout
Methods inherited from StaticFile
#==, #initialize, #inspect, #render
Methods included from Helpers::Indexer
Constructor Details
This class inherits a constructor from Usmu::Template::Layout
Instance Attribute Details
#arguments ⇒ Hash
Returns the arguments associated with this include.
18 19 20 |
# File 'lib/usmu/template/include.rb', line 18 def arguments @arguments end |
#content_path ⇒ string (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.
71 72 73 |
# File 'lib/usmu/template/include.rb', line 71 def content_path @configuration.includes_path end |
#metadata ⇒ Hash (readonly)
Returns the metadata associated with this layout.
This will include any metadata from parent templates and default metadata
53 54 55 56 57 58 59 |
# File 'lib/usmu/template/include.rb', line 53 def = # Includes must never allow layout inheritance. ['layout'] = nil end |
Class Method Details
.find_include(configuration, name) ⇒ Usmu::Layout
Static method to create an include for a given configuration by it's name if it exists. This differs from
#initialise
in that it allows different types of values to be supplied as the name and will not fail if name
is nil
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/usmu/template/include.rb', line 30 def self.find_include(configuration, name) if name === 'none' nil elsif name.class.name == 'String' Dir["#{configuration.includes_path}/#{name}.*"].each do |f| filename = File.basename(f) if filename != "#{name}.meta.yml" path = f[(configuration.includes_path.length + 1)..f.length] return new(configuration, path, configuration..(path)) end end nil else name end end |
Instance Method Details
#get_variables(variables) ⇒ Hash (private)
Utility function which collates variables to pass to the template engine.
80 81 82 83 84 85 86 87 |
# File 'lib/usmu/template/include.rb', line 80 def get_variables(variables) args = {} arguments.each do |i, value| args[i.class.name == 'String' ? i : i.to_s] = value end {'site' => @configuration}.deep_merge!().deep_merge!(args).deep_merge!(variables) end |
#layout_metadata ⇒ void (private)
Preserved version of the layout metadata logic
12 |
# File 'lib/usmu/template/include.rb', line 12 alias :layout_metadata :metadata |