module Octopress::TagHelpers::ContentFor

Public Class Methods

append_to_block(context, block, content) click to toggle source
# File lib/octopress-tag-helpers/content_for.rb, line 22
def self.append_to_block(context, block, content)
  converter = context.environments.first['converter']
  content = converter.convert(content).sub(/\n$/,'')
  get_block(context, block) << content
end
get_block(context, block) click to toggle source

Gets the storage space for the content block

# File lib/octopress-tag-helpers/content_for.rb, line 13
def self.get_block(context, block)
  context.environments.first['content_for'] ||= {}
  context.environments.first['content_for'][block] ||= []
end
get_block_name(tag_name, markup) click to toggle source
# File lib/octopress-tag-helpers/content_for.rb, line 4
def self.get_block_name(tag_name, markup)
  if markup.strip == ''
    raise IOError.new "Syntax Error: #{tag_name} requires a name, eg. {% #{tag_name} sidebar %}"
  else
    markup.strip
  end
end
render(context, block) click to toggle source
# File lib/octopress-tag-helpers/content_for.rb, line 18
def self.render(context, block)
  content = get_block(context, block).map { |b| b }.join
end