Sha256: e87faf1563a42133ad92cf8d238e1e533b4568f17bfc2f474a150d38018354e8

Contents?: true

Size: 706 Bytes

Versions: 1

Compression:

Stored size: 706 Bytes

Contents

module Bunto
  module Tags
    class Link < Liquid::Tag
      TagName = 'link'

      def initialize(tag_name, relative_path, tokens)
        super

        @relative_path = relative_path.strip
      end

      def render(context)
        site = context.registers[:site]

        site.docs_to_write.each do |document|
          return document.url if document.relative_path == @relative_path
        end

        raise ArgumentError, "Could not find document '#{@relative_path}' in tag '#{TagName}'.\n\n" \
          "Make sure the document exists and the path is correct."
      end
    end
  end
end

Liquid::Template.register_tag(Bunto::Tags::Link::TagName, Bunto::Tags::Link)

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
bunto-3.0.0 lib/bunto/tags/link.rb