Module: Nyara::View::Renderable

Defined in:
lib/nyara/view.rb

Class Method Summary collapse

Class Method Details

.make_layout_method(nested_level = 0) ⇒ Object


86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
# File 'lib/nyara/view.rb', line 86

def self.make_layout_method nested_level=0
  sig = 'e'
  src = "e.call locals"
  nested_level.times do |i|
    sig << ", e#{i}"
    src = "e#{i}.call{ #{src} }"
  end
  sig = "#{sig}"
  class_eval <<-RUBY
    def layout #{sig}, locals
      #{src}
    end
  RUBY
  instance_method(:layout).bind self
end

.make_render_method(file, line, sig, src) ⇒ Object


77
78
79
80
81
82
83
84
# File 'lib/nyara/view.rb', line 77

def self.make_render_method file, line, sig, src
  class_eval <<-RUBY, file, line
    def render#{sig}
      #{src}
    end
  RUBY
  instance_method :render
end