Module: Middleman::Graphviz::Helpers

Defined in:
lib/middleman/graphviz/helpers.rb

Instance Method Summary collapse

Instance Method Details

#graphviz(&block) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/middleman/graphviz/helpers.rb', line 6

def graphviz( &block )
  if block_given?
    data = capture_html(&block)

    out, err, status = Open3.capture3( "dot -Tsvg", stdin_data: data )

    # puts "Status = #{status}"
    # puts err

    svg = out.gsub( /.*<svg/m, "<svg" ).gsub( /\n/m, "")

    concat_content(svg.html_safe)
  end
end