Sha256: 4dcc65b458140561d0c88ec1360eef2adfa1d17e804e210b8c09f2309a68b12b

Contents?: true

Size: 795 Bytes

Versions: 3

Compression:

Stored size: 795 Bytes

Contents

module Octopress
  module Tags
    class EmbedTag < Liquid::Tag
      EMBED_SYNTAX = /(.+?)\/(\S+)/

      def initialize(tag_name, markup, tokens)
        super
        @markup = markup
        if @markup.strip =~ EMBED_SYNTAX
          @plugin = $1
          @path = $2
        else
          raise IOError.new "Invalid Syntax: for embed tag. {% embed #{@markup.strip} %} should be {% embed plugin/file %}"
        end
      end

      def render(context)
        content = Plugins.embed(@plugin, @path, context.registers[:site]).read
        partial = Liquid::Template.parse(content)
        context.stack {
          context['embed'] = Jekyll::Tags::IncludeTag.new('include', @markup, []).parse_params(context)
          partial.render!(context)
        }.strip
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
octopress-ink-1.0.0.alpha.14 lib/octopress-ink/tags/embed.rb
octopress-ink-1.0.0.alpha.13 lib/octopress-ink/tags/embed.rb
octopress-ink-1.0.0.alpha.12 lib/octopress-ink/tags/embed.rb