Class: Mack::Rendering::Type::Layout

Inherits:
FileBase show all
Defined in:
lib/mack/rendering/type/layout.rb

Overview

Used to render layouts around views.

Instance Attribute Summary

Attributes inherited from Base

#view_template

Instance Method Summary collapse

Methods inherited from FileBase

#concat, #render_file

Methods inherited from Base

#allow_layout?, #capture, #controller_view_path, #find_engine, #find_file, #initialize, #method_missing

Constructor Details

This class inherits a constructor from Mack::Rendering::Type::Base

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Mack::Rendering::Type::Base

Instance Method Details

#renderObject

See Mack::Rendering::Type::FileBase render_file for more information.

The path to the file is built like such:

app/views/layouts/#{options[:layout] || "application"}.#{format (html, xml, js, etc...)}.#{extension defined in the engine}

Example:

app/views/layouts/application.html.erb


14
15
16
17
18
19
20
21
22
# File 'lib/mack/rendering/type/layout.rb', line 14

def render
  l_file = Mack::Paths.layouts("#{self._options[:layout]}.#{self._options[:format]}")
  begin
    render_file(l_file, :layout)
  rescue Mack::Errors::ResourceNotFound => e
    Mack.logger.warn(e)
    self.view_template.yield_to :view
  end
end