Sha256: 86f9d3ad866a3212f3476c233d3cfe96e046de4fa04b830e8cfa521f4b65deaa

Contents?: true

Size: 774 Bytes

Versions: 12

Compression:

Stored size: 774 Bytes

Contents

module PufferPages
  module Liquid
    module Tags

      class Yield < ::Liquid::Tag
        Syntax = /^(#{::Liquid::QuotedFragment})/

        def initialize(tag_name, markup, tokens)
          if markup =~ Syntax
            @name = $1
          else
            @name = "'#{PufferPages.primary_page_part_name}'"
          end

          super
        end

        def render(context)
          name = context[@name]
          part = context.registers[:page].part(name)
          if part
            part.render(context)
          else
            raise ArgumentError.new("Argument error in 'yield' - Can not find page part named '#{name}'")
          end
        end
      end

    end
  end
end

Liquid::Template.register_tag('yield', PufferPages::Liquid::Tags::Yield)

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
puffer_pages-0.0.19 lib/puffer_pages/liquid/tags/yield.rb
puffer_pages-0.0.18 lib/puffer_pages/liquid/tags/yield.rb
puffer_pages-0.0.17 lib/puffer_pages/liquid/tags/yield.rb
puffer_pages-0.0.16 lib/puffer_pages/liquid/tags/yield.rb
puffer_pages-0.0.15 lib/puffer_pages/liquid/tags/yield.rb
puffer_pages-0.0.14 lib/puffer_pages/liquid/tags/yield.rb
puffer_pages-0.0.13 lib/puffer_pages/liquid/tags/yield.rb
puffer_pages-0.0.12 lib/puffer_pages/liquid/tags/yield.rb
puffer_pages-0.0.11 lib/puffer_pages/liquid/tags/yield.rb
puffer_pages-0.0.10 lib/puffer_pages/liquid/tags/yield.rb
puffer_pages-0.0.9 lib/puffer_pages/liquid/tags/yield.rb
puffer_pages-0.0.8 lib/puffer_pages/liquid/tags/yield.rb