Sha256: 083c907e30f92e4eac0b5ebad00297ac67b0472720780fb5f75de9c9e0af2d48

Contents?: true

Size: 690 Bytes

Versions: 1

Compression:

Stored size: 690 Bytes

Contents

module Jekyll
    module Diagrams
      class ErdBlock < Block
        CONFIGURATIONS = %w(config edge).freeze
        
        def render_svg(code, config)
          svg = render_with_stdin_stdout(build_command(config), 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

1 entries across 1 versions & 1 rubygems

Version Path
jekyll-diagrams-0.7.1 lib/jekyll-diagrams/erd.rb