Sha256: 2a6405b3e1c50e8db5b7fa71f4d044b2060d31228e669ca93ebe0571178e84ce

Contents?: true

Size: 950 Bytes

Versions: 24

Compression:

Stored size: 950 Bytes

Contents

module Octopress
  module Ink
    module Helpers
      module ContentFor
        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

        # Gets the storage space for the content block
        def self.get_block(context, block)
          context.environments.first['content_for'] ||= {}
          context.environments.first['content_for'][block] ||= []
        end

        def self.render(context, block)
          content = get_block(context, block).map { |b| b }.join
        end

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

Version data entries

24 entries across 24 versions & 1 rubygems

Version Path
octopress-ink-1.0.0.alpha.35 lib/octopress-ink/helpers/content_for.rb
octopress-ink-1.0.0.alpha.34 lib/octopress-ink/helpers/content_for.rb
octopress-ink-1.0.0.alpha.33 lib/octopress-ink/helpers/content_for.rb
octopress-ink-1.0.0.alpha.32 lib/octopress-ink/helpers/content_for.rb