Class: Vedeu::Renderers::HTML
- Defined in:
- lib/vedeu/output/renderers/html.rb
Overview
Renders a Terminal::Buffer as a HTML snippet; a table by default.
Instance Attribute Summary collapse
-
#options ⇒ Hash<Symbol => void>
included
from Options
private
Combines the options provided at instantiation with the default values.
Instance Method Summary collapse
-
#clear ⇒ String
Render a cleared output.
- #default_template ⇒ String private
-
#defaults ⇒ Hash<Symbol => void>
private
The default values for a new instance of this class.
- #end_row_tag ⇒ String private
- #end_tag ⇒ String private
-
#escape? ⇒ Boolean
private
Returns a boolean indicating whether the output is a Models::Escape.
- #html_body ⇒ String
-
#initialize(options = {}) ⇒ Vedeu::Renderers::HTML
constructor
Returns a new instance of Vedeu::Renderers::HTML.
- #output ⇒ Array<Array<Vedeu::Views::Char>> private
- #render(output) ⇒ String
- #start_row_tag ⇒ String private
- #start_tag ⇒ String private
- #template ⇒ String private
Constructor Details
#initialize(options = {}) ⇒ Vedeu::Renderers::HTML
Returns a new instance of Vedeu::Renderers::HTML.
28 29 30 31 |
# File 'lib/vedeu/output/renderers/html.rb', line 28 def initialize( = {}) @options = || {} @output = nil end |
Instance Attribute Details
#options ⇒ Hash<Symbol => void> (private) Originally defined in module Options
Combines the options provided at instantiation with the default values.
Instance Method Details
#clear ⇒ String
Render a cleared output.
36 37 38 39 40 |
# File 'lib/vedeu/output/renderers/html.rb', line 36 def clear @output = Vedeu::Models::Escape.new '' end |
#default_template ⇒ String (private)
124 125 126 |
# File 'lib/vedeu/output/renderers/html.rb', line 124 def default_template ::File.dirname(__FILE__) + '/../templates/html_renderer.vedeu' end |
#defaults ⇒ Hash<Symbol => void> (private)
The default values for a new instance of this class.
109 110 111 112 113 114 115 116 117 118 119 120 121 |
# File 'lib/vedeu/output/renderers/html.rb', line 109 def defaults { content: '', end_tag: '</td>', end_row_tag: '</tr>', filename: 'out', start_tag: '<td', start_row_tag: '<tr>', template: default_template, timestamp: false, write_file: true, } end |
#end_row_tag ⇒ String (private)
87 88 89 |
# File 'lib/vedeu/output/renderers/html.rb', line 87 def end_row_tag [:end_row_tag] end |
#end_tag ⇒ String (private)
82 83 84 |
# File 'lib/vedeu/output/renderers/html.rb', line 82 def end_tag [:end_tag] end |
#escape? ⇒ Boolean (private)
Returns a boolean indicating whether the output is a Models::Escape. If it is, it won’t be rendered in HTML.
72 73 74 |
# File 'lib/vedeu/output/renderers/html.rb', line 72 def escape? output.is_a?(Vedeu::Models::Escape) end |
#html_body ⇒ String
51 52 53 54 55 56 57 58 59 60 61 62 63 |
# File 'lib/vedeu/output/renderers/html.rb', line 51 def html_body return '' if output.is_a?(Vedeu::Models::Escape) out = '' output.each do |line| out << "#{start_row_tag}\n" line.each { |char| out << char.to_html() } out << "#{end_row_tag}\n" end out end |
#output ⇒ Array<Array<Vedeu::Views::Char>> (private)
77 78 79 |
# File 'lib/vedeu/output/renderers/html.rb', line 77 def output @output || [:output] end |
#render(output) ⇒ String
44 45 46 47 48 |
# File 'lib/vedeu/output/renderers/html.rb', line 44 def render(output) @output = output super(Vedeu::Templating::Template.parse(self, template)) unless escape? end |
#start_row_tag ⇒ String (private)
97 98 99 |
# File 'lib/vedeu/output/renderers/html.rb', line 97 def start_row_tag [:start_row_tag] end |
#start_tag ⇒ String (private)
92 93 94 |
# File 'lib/vedeu/output/renderers/html.rb', line 92 def start_tag [:start_tag] end |
#template ⇒ String (private)
102 103 104 |
# File 'lib/vedeu/output/renderers/html.rb', line 102 def template [:template] end |