Module: Olelo::BlockHelper

Included in:
ApplicationHelper
Defined in:
lib/olelo/helper.rb

Instance Method Summary collapse

Instance Method Details

#blocksObject



4
5
6
# File 'lib/olelo/helper.rb', line 4

def blocks
  @blocks ||= Hash.new('')
end

#define_block(name, content = nil, &block) ⇒ Object



8
9
10
11
# File 'lib/olelo/helper.rb', line 8

def define_block(name, content = nil, &block)
  blocks[name] = block ? block : escape_html(content)
  ''
end

#include_block(name) ⇒ Object



18
19
20
# File 'lib/olelo/helper.rb', line 18

def include_block(name)
  wrap_block(name) { render_block(name) }
end

#render_block(name) ⇒ Object



13
14
15
16
# File 'lib/olelo/helper.rb', line 13

def render_block(name)
  block = blocks[name]
  block.respond_to?(:call) ? block.call : block
end

#wrap_block(name) ⇒ Object



22
23
24
# File 'lib/olelo/helper.rb', line 22

def wrap_block(name)
  with_hooks(name) { yield }.join.html_safe
end