Sha256: 7a47237308bc21cbea76abef7518839d96a90fff6da1d97934a64732e9dae207

Contents?: true

Size: 781 Bytes

Versions: 8

Compression:

Stored size: 781 Bytes

Contents

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

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

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

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

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

  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
end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
hydeweb-0.2.2 lib/hyde/helpers.rb
hydeweb-0.1.14 lib/hyde/helpers.rb
hydeweb-0.1.13 lib/hyde/helpers.rb
hydeweb-0.1.12 lib/hyde/helpers.rb
hydeweb-0.1.11 lib/hyde/helpers.rb
hydeweb-0.1.10 lib/hyde/helpers.rb
hydeweb-0.1.9 lib/hyde/helpers.rb
hydeweb-0.1.8 lib/hyde/helpers.rb