Class: Yuzu::Core::PageLayout

Inherits:
Object
  • Object
show all
Defined in:
lib/yuzu/core/layout.rb

Overview

A class that encapsulates the variables in the ‘layout` namespace in the Haml layout. This means that the user can access variables passed into the `kwds` hash with dot notation on `layout`. For example:

layout.head - Refers to the rendered contents of _head.haml

Instance Method Summary collapse

Constructor Details

#initialize(website_file, kwds = {}) ⇒ PageLayout

Returns a new instance of PageLayout.



73
74
75
76
77
78
79
80
81
# File 'lib/yuzu/core/layout.rb', line 73

def initialize(website_file, kwds={})
  kwds.each_pair do |method_name, template_obj|
    (class << self; self; end).class_eval do
      define_method method_name.to_sym do
        template_obj.render(website_file)
      end
    end
  end
end