Module: Erector::HTML::ClassMethods

Defined in:
lib/erector/html.rb

Instance Method Summary collapse

Instance Method Details

#all_tagsObject



35
36
37
# File 'lib/erector/html.rb', line 35

def all_tags
  full_tags + empty_tags
end

#def_empty_tag_method(tag_name) ⇒ Object



39
40
41
42
43
44
45
# File 'lib/erector/html.rb', line 39

def def_empty_tag_method(tag_name)
  self.class_eval(<<-SRC, __FILE__, __LINE__ + 1)
    def #{tag_name}(*args, &block)
      __empty_element__('#{tag_name}', *args, &block)
    end
  SRC
end

#def_full_tag_method(tag_name) ⇒ Object



47
48
49
50
51
52
53
54
55
56
57
# File 'lib/erector/html.rb', line 47

def def_full_tag_method(tag_name)
  self.class_eval(<<-SRC, __FILE__, __LINE__ + 1)
    def #{tag_name}(*args, &block)
        __element__(false, '#{tag_name}', *args, &block)
    end

    def #{tag_name}!(*args, &block)
      __element__(true, '#{tag_name}', *args, &block)
    end
  SRC
end

#empty_tagsObject

Tags which are always self-closing. Click “[show source]” to see the full list.



5
6
7
8
# File 'lib/erector/html.rb', line 5

def empty_tags
  ['area', 'base', 'br', 'col', 'embed', 'frame',
  'hr', 'img', 'input', 'link', 'meta', 'param']
end

#full_tagsObject

Tags which can contain other stuff. Click “[show source]” to see the full list.



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/erector/html.rb', line 11

def full_tags
  [
    'a', 'abbr', 'acronym', 'address', 'article', 'aside', 'audio',
    'b', 'bdo', 'big', 'blockquote', 'body', 'button',
    'canvas', 'caption', 'center', 'cite', 'code', 'colgroup', 'command',
    'datalist', 'dd', 'del', 'details', 'dfn', 'dialog', 'div', 'dl', 'dt',
    'em',
    'fieldset', 'figure', 'footer', 'form', 'frameset',
    'h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'head', 'header', 'hgroup', 'html', 'i',
    'iframe', 'ins', 'keygen', 'kbd', 'label', 'legend', 'li',
    'map', 'mark', 'meter',
    'nav', 'noframes', 'noscript',
    'object', 'ol', 'optgroup', 'option',
    'p', 'pre', 'progress',
    'q', 'ruby', 'rt', 'rp', 's',
    'samp', 'script', 'section', 'select', 'small', 'source', 'span', 'strike',
    'strong', 'style', 'sub', 'sup',
    'table', 'tbody', 'td', 'textarea', 'tfoot',
    'th', 'thead', 'time', 'title', 'tr', 'tt',
    'u', 'ul',
    'var', 'video'
  ]
end