Module: Viewlet::Helpers

Defined in:
lib/viewlet/helpers.rb

Instance Method Summary collapse

Instance Method Details

#viewlet(name, variables = {}, options = {}, &block) ⇒ Object



3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
# File 'lib/viewlet/helpers.rb', line 3

def viewlet(name, variables={}, options={}, &block)
  klass = options[:class_name].try(:constantize) || Base
  viewlet = klass.new(name, self)

  variables.each do |name, value|
    viewlet.send(name, value)
  end

  case block.arity
    when 0 then block.call
    when 1 then block.call(viewlet)
  end if block_given?

  viewlet.render
end