Sha256: b1ca91a56efb84d45e7eb3c7a1f8b6fae25289f8d9a4cd7f853d478057f0cf94

Contents?: true

Size: 861 Bytes

Versions: 1

Compression:

Stored size: 861 Bytes

Contents

module Jekyll
  module Maps
    class GoogleMapTag < Liquid::Tag
      def initialize(_, args, _)
        options = OptionsParser.parse(args)
        @finder = LocationFinder.new(options)
        super
      end

      def render(context)
        template.render!({
          "locations" => @finder.find(context.registers[:site]).to_json
        })
      end

      private
      def template
        @template ||= Liquid::Template.parse(template_contents)
      end

      private
      def template_contents
        @template_contents ||= begin
          File.read(template_path)
        end
      end

      private
      def template_path
        @template_path ||= begin
          File.expand_path("./google_map.html", File.dirname(__FILE__))
        end
      end
    end
  end
end

Liquid::Template.register_tag("google_map", Jekyll::Maps::GoogleMapTag)

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
jekyll-maps-1.0.2 lib/jekyll-maps/google_map_tag.rb