Sha256: fe7f6ad041338624d7975e3d670be36a01e73f3a59462e170e5030ea546efa44

Contents?: true

Size: 669 Bytes

Versions: 3

Compression:

Stored size: 669 Bytes

Contents

module Jekyll
  module Diagrams
    class ErdBlock < Block
      CONFIGURATIONS = %w( config edge ).freeze

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

        svg = render_with_stdin_stdout(command, code)
        svg.sub!(/^<\?xml(([^>]|\n)*>\n?){2}/, '')
      end

      def build_command(config)
        command = 'erd --fmt=svg'
        command << ' --dot-entity' if config.has_key?('dot-entity')

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

        command
      end
    end
  end
end

Liquid::Template.register_tag(:erd, Jekyll::Diagrams::ErdBlock)

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
jekyll-diagrams-0.9.1 lib/jekyll-diagrams/erd.rb
jekyll-diagrams-0.9.0 lib/jekyll-diagrams/erd.rb
jekyll-diagrams-0.8.0 lib/jekyll-diagrams/erd.rb