Sha256: 72144d52425fd52ad758f6d5e75de10ae1bba9110a21df3d2290fbd51e23518b

Contents?: true

Size: 647 Bytes

Versions: 2

Compression:

Stored size: 647 Bytes

Contents

module Jekyll
  module Diagrams
    class VegaBlock < Block
      CONFIGURATIONS = %w( scale )

      def render_svg(code, config)
        command = build_command(config)

        render_with_stdin_stdout(command, code)
      end

      def build_command(config)
        command = case block_name
        when 'vega'
          'vg2svg'
        when 'vegalite'
          'vl2svg'
        end

        CONFIGURATIONS.each do |conf|
          command << " --#{conf} #{config[conf]}" if config.has_key?(conf)
        end
      end
    end
  end
end

%i(vega vegalite).each do |tag|
  Liquid::Template.register_tag(tag, Jekyll::Diagrams::VegaBlock)
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
jekyll-diagrams-0.9.0 lib/jekyll-diagrams/vega.rb
jekyll-diagrams-0.8.0 lib/jekyll-diagrams/vega.rb