Class: Alf::Renderer::Html

Inherits:
Alf::Renderer show all
Defined in:
lib/alf/renderer/html.rb

Constant Summary

Constants inherited from Alf::Renderer

DEFAULT_OPTIONS

Instance Attribute Summary

Attributes inherited from Alf::Renderer

#input, #options

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Alf::Renderer

by_mime_type, #execute, #initialize, register, renderer

Methods included from Support::Registry

#listen, #listeners, #register, #registered

Constructor Details

This class inherits a constructor from Alf::Renderer

Class Method Details

.mime_typeObject


5
6
7
# File 'lib/alf/renderer/html.rb', line 5

def self.mime_type
  "text/html"
end

.render(input, output, options = {}) ⇒ Object


31
32
33
# File 'lib/alf/renderer/html.rb', line 31

def self.render(input, output, options= {})
  new(input, options).execute(output)
end

Instance Method Details

#each {|"<table class=\"table table-condensed table-bordered table-striped\">"| ... } ⇒ Object

Yields:

  • ("<table class=\"table table-condensed table-bordered table-striped\">")

9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/alf/renderer/html.rb', line 9

def each
  return to_enum unless block_given?
  yield "<table class=\"table table-condensed table-bordered table-striped\">"
  header = nil
  each_tuple do |tuple|
    unless header
      header = tuple.keys
      yield "<thead><tr>"
      header.each do |attrname|
        yield "<th>#{attrname}</th>"
      end
      yield "</tr></thead><tbody>"
    end
    yield "<tr>"
    header.each do |attrname|
      yield "<td>#{render_value tuple[attrname]}</td>"
    end
    yield "</tr>"
  end
  yield "</tbody></table>"
end