Class: Trickster::Renderer::CommandlineRenderer

Inherits:
Object
  • Object
show all
Defined in:
lib/trickster/renderer/commandline_renderer.rb

Instance Method Summary collapse

Instance Method Details

#render(io, content, options) ⇒ Object



4
5
6
7
8
9
10
11
12
13
14
# File 'lib/trickster/renderer/commandline_renderer.rb', line 4

def render(io,content,options)
  io.print "<pre><code class='no-highlight'>"
  content = split_by_commands_and_results(content)
  content.each do |(prompt,command,result)|
    io.puts "<span class='cli-prompt'>#{prompt}</span> <span class='cli-element cli-command cli-line'>#{command}</span>"
    unless result.empty?
      io.puts "<span class='cli-element cli-result'>#{result.join("\n")}</span>"
    end
  end
  io.puts "</code></pre>"
end