Sha256: ab58a3d13b8f460ed8a5a26b284604b846805eafb9e2cd353bc9718237bcf064
Contents?: true
Size: 871 Bytes
Versions: 1
Compression:
Stored size: 871 Bytes
Contents
# frozen_string_literal: true module Jekyll module Diagrams class ErdBlock < Block XML_REGEX = /^<\?xml(([^>]|\n)*>\n?){2}/.freeze CONFIGURATIONS = %w[config edge].freeze SWITCHES = { 'dot-entity' => false }.freeze def render_svg(code, config) command = build_command(config) svg = render_with_stdin_stdout(command, code) svg.sub!(XML_REGEX, '') end def build_command(config) command = +'erd --fmt=svg' SWITCHES.merge(config.slice(*SWITCHES.keys)).each do |switch, value| command << " --#{switch}" if value != false end CONFIGURATIONS.each do |conf| command << " --#{conf}=#{config[conf]}" if config.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.9.3 | lib/jekyll-diagrams/erd.rb |