class Mustermann::Visualizer::Renderer::HTML
Generates HTML
output. @!visibility private
Public Class Methods
new(target, tag: :span, class_prefix: "mustermann_", css: :inline, **options)
click to toggle source
@!visibility private
Calls superclass method
Mustermann::Visualizer::Renderer::Generic::new
# File lib/mustermann/visualizer/renderer/html.rb, line 12 def initialize(target, tag: :span, class_prefix: "mustermann_", css: :inline, **options) raise ArgumentError, 'css option %p not supported, should be true, false or inline' if css != true and css != false and css != :inline super(target, **options) @css, @tag, @class_prefix = css, tag, class_prefix end
Public Instance Methods
escape_string(string)
click to toggle source
@!visibility private
# File lib/mustermann/visualizer/renderer/html.rb, line 29 def escape_string(string) CGI.escape_html(string) end
post(type)
click to toggle source
@!visibility private
# File lib/mustermann/visualizer/renderer/html.rb, line 44 def post(type) "</#{@tag}>" end
pre(type)
click to toggle source
@!visibility private
# File lib/mustermann/visualizer/renderer/html.rb, line 34 def pre(type) if @css == :inline return "" unless rule = @target.theme[type] "<#{@tag} style=\"#{rule.to_css_rule}\">" else "<#{@tag} class=\"#{@class_prefix}#{type}\">" end end
preamble()
click to toggle source
@!visibility private
# File lib/mustermann/visualizer/renderer/html.rb, line 19 def preamble "<style type=\"text/css\">\n%s</style>" % stylesheet if @css == true end
stylesheet()
click to toggle source
@!visibility private
# File lib/mustermann/visualizer/renderer/html.rb, line 24 def stylesheet @target.theme.to_css { |name| ".#{@class_prefix}pattern .#{@class_prefix}#{name}" } end