Module: Hyde::Helpers

Defined in:
lib/hyde/helpers.rb

Instance Method Summary collapse

Instance Method Details

#content_blocksObject



18
19
20
21
# File 'lib/hyde/helpers.rb', line 18

def content_blocks
  $content_blocks ||= Hash.new
  $content_blocks[page.path] ||= Hash.new
end

#content_for(key, &blk) ⇒ Object



14
15
16
# File 'lib/hyde/helpers.rb', line 14

def content_for(key, &blk)
  content_blocks[key.to_sym] = blk
end

#has_content?(key) ⇒ Boolean

Returns:

  • (Boolean)


23
24
25
# File 'lib/hyde/helpers.rb', line 23

def has_content?(key)
  content_blocks.member? key.to_sym
end

#partial(path, locals = {}) ⇒ Object



3
4
5
6
# File 'lib/hyde/helpers.rb', line 3

def partial(path, locals={})
  partial = Partial[path.to_s, page]  or return ''
  partial.to_html locals.merge(:page => self)
end

#rel(path) ⇒ Object



8
9
10
11
12
# File 'lib/hyde/helpers.rb', line 8

def rel(path)
  depth = page.depth
  dotdot = depth > 1 ? ('../' * (page.depth-1)) : './'
  (dotdot[0...-1] + path)
end

#yield_content(key, *args) ⇒ Object



27
28
29
30
31
32
33
34
# File 'lib/hyde/helpers.rb', line 27

def yield_content(key, *args)
  content = content_blocks[key.to_sym]
  if respond_to?(:block_is_haml?) && block_is_haml?(content)
    capture_haml(*args, &content)
  elsif content
    content.call(*args)
  end
end