Class: Jekyll::Diagrams::SyntraxRenderer

Inherits:
BasicRenderer show all
Defined in:
lib/jekyll-diagrams/syntrax/renderer.rb

Constant Summary collapse

CONFIGURATIONS =
%w[scale style].freeze

Instance Method Summary collapse

Methods inherited from BasicRenderer

#initialize, render, #render

Methods included from Rendering

render_with_command, render_with_stdin_stdout, render_with_tempfile

Constructor Details

This class inherits a constructor from Jekyll::Diagrams::BasicRenderer

Instance Method Details

#build_command(config) ⇒ Object



16
17
18
19
20
21
22
23
24
# File 'lib/jekyll-diagrams/syntrax/renderer.rb', line 16

def build_command(config)
  command = +'syntrax'

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

  command
end

#render_svg(code, config) ⇒ Object



8
9
10
11
12
13
14
# File 'lib/jekyll-diagrams/syntrax/renderer.rb', line 8

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

  render_with_tempfile(command, code) do |input, output|
    "--input #{input} --output #{output}"
  end
end