Sha256: be4e0e0aaebeff04531837fa73f34df71888bdf5029bc7949c63efea91a18e3a

Contents?: true

Size: 1.01 KB

Versions: 24

Compression:

Stored size: 1.01 KB

Contents

# Inspired by jekyll-contentblocks https://github.com/rustygeldmacher/jekyll-contentblocks
#
module Octopress
  module Ink
    module Tags
      class YieldTag < Liquid::Tag

        def initialize(tag_name, markup, tokens)
          if markup.strip == ''
            raise IOError.new "Yield failed: {% #{tag_name} #{markup}%}. Please provide a block name to yield. - Syntax: {% yield block_name %}"
          end

          super
          @markup = markup
          if markup =~ Helpers::Var::HAS_FILTERS
            markup = $1
            @filters = $2
          end
          @block_name = Helpers::ContentFor.get_block_name(tag_name, markup)
        end

        def render(context)
          return unless markup = Helpers::Conditional.parse(@markup, context)
          content = Helpers::ContentFor.render(context, @block_name)

          unless content.nil? || @filters.nil?
            content = Helpers::Var.render_filters(content, @filters, context)
          end

          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/tags/yield.rb
octopress-ink-1.0.0.alpha.34 lib/octopress-ink/tags/yield.rb
octopress-ink-1.0.0.alpha.33 lib/octopress-ink/tags/yield.rb
octopress-ink-1.0.0.alpha.32 lib/octopress-ink/tags/yield.rb