-
-
Notifications
You must be signed in to change notification settings - Fork 75
/
html5_elements.rb
47 lines (39 loc) · 1.64 KB
/
html5_elements.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
module Arbre
module HTML
AUTO_BUILD_ELEMENTS = [ :a, :abbr, :address, :area, :article, :aside, :audio, :b, :base,
:bdo, :blockquote, :body, :br, :button, :canvas, :caption, :cite,
:code, :col, :colgroup, :command, :datalist, :dd, :del, :details,
:dfn, :div, :dl, :dt, :em, :embed, :fieldset, :figcaption, :figure,
:footer, :form, :h1, :h2, :h3, :h4, :h5, :h6, :head, :header, :hgroup,
:hr, :html, :i, :iframe, :img, :input, :ins, :keygen, :kbd, :label,
:legend, :li, :link, :map, :mark, :menu, :menuitem, :meta, :meter, :nav, :noscript,
:object, :ol, :optgroup, :option, :output, :param, :pre, :progress, :q,
:s, :samp, :script, :section, :select, :small, :source, :span,
:strong, :style, :sub, :summary, :sup, :svg, :table, :tbody, :td,
:textarea, :tfoot, :th, :thead, :time, :title, :tr, :track, :ul, :var, :video, :wbr ]
HTML5_ELEMENTS = [ :p ] + AUTO_BUILD_ELEMENTS
AUTO_BUILD_ELEMENTS.each do |name|
class_eval <<-EOF
class #{name.to_s.capitalize} < Tag
builder_method :#{name}
end
EOF
end
class P < Tag
builder_method :para
end
class Table < Tag
def initialize(*)
super
set_table_tag_defaults
end
protected
# Set some good defaults for tables
def set_table_tag_defaults
set_attribute :border, 0
set_attribute :cellspacing, 0
set_attribute :cellpadding, 0
end
end
end
end