Module: Rhtml

Defined in:
lib/rhtml/tag.rb,
lib/rhtml/html.rb,
lib/rhtml/version.rb,
lib/rhtml/shortcut.rb

Defined Under Namespace

Classes: Html

Constant Summary collapse

INDENT =
'  '
VOID_TAGS =
%w{area base br col command embed hr img input keygen link meta param source track wbr}
TAGS =
%w{a abbr acronym address applet area article aside audio b base basefont bdi
bdo big blockquote body br canvas caption center cite code col colgroup command
datalist dd del details dfn dialog dir div dl dt em embed fieldset figcaption
figure font footer form frame frameset h1 head header hgroup hr html i iframe
img input ins kbd keygen label legend li link map mark menu meta meter nav noframes
noscript object ol optgroup option output p param pre progress q rp rt ruby s samp
script section select small source span strike strong style sub summary sup table tbody
td textarea tfoot th thead time title tr track tt u ul var video wbr}
VERSION =
"0.0.8"

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.properties(ps) ⇒ Object



16
17
18
# File 'lib/rhtml/tag.rb', line 16

def Rhtml.properties ps
  ps.map { |p| "#{p[0].to_s.gsub("_", "-")}='#{p[1].to_s}'" }.join(' ')
end

.tag_close(tag_name, indent) ⇒ Object



28
29
30
# File 'lib/rhtml/tag.rb', line 28

def Rhtml.tag_close tag_name, indent
  "#{INDENT * indent}</#{tag_name}>\n"
end

.tag_open(tag_name, ps = {}, indent) ⇒ Object



24
25
26
# File 'lib/rhtml/tag.rb', line 24

def Rhtml.tag_open tag_name, ps={}, indent
  "#{INDENT * indent}<#{tag_name}#{' ' << properties(ps) unless ps.empty?}>\n"
end

.void_tag(tag_name, ps = {}, indent) ⇒ Object



20
21
22
# File 'lib/rhtml/tag.rb', line 20

def Rhtml.void_tag tag_name, ps={}, indent
  "#{INDENT * indent}<#{tag_name}#{' ' << properties(ps) unless ps.empty?}/>\n"
end

Instance Method Details

#html!(&b) ⇒ Object



2
3
4
# File 'lib/rhtml/shortcut.rb', line 2

def html!(&b)
  Rhtml::Html.new.html(&b)
end