Module: Arbre::Html

Defined in:
lib/arbre.rb,
lib/arbre/html/tag.rb,
lib/arbre/html/comment.rb,
lib/arbre/html/document.rb,
lib/arbre/html/querying.rb,
lib/arbre/html/html_tags.rb,
lib/arbre/html/attributes.rb,
lib/arbre/html/class_list.rb

Defined Under Namespace

Modules: Querying Classes: Attributes, ClassList, Comment, Document, Query, Tag

Constant Summary collapse

SELF_CLOSING_TAGS =

This file creates a class for all known HTML 5 tags. You can derive from these classes to build specialized versions.

%w[
  input img col br meta link
]
OTHER_TAGS =
%w[
  a abbr address area article aside audio b base
  bdo blockquote body button canvas caption cite
  code 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 ins keygen kbd label
  legend li map mark menu meter nav noscript
  object ol optgroup option output pre progress q
  s samp script section select small source span
  strong style sub summary sup table tbody td
  textarea tfoot th thead time title tr ul var video
]

Class Method Summary collapse

Class Method Details

.create_tag_class(tag, builder_method = tag.to_sym, self_closing: false) ⇒ Object



24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/arbre/html/html_tags.rb', line 24

def self.create_tag_class(tag, builder_method = tag.to_sym, self_closing: false)
  self_closing_method = self_closing ? 'def self_closing_tag?() true end' : ''

  module_eval <<-RUBY, __FILE__, __LINE__+1
    class #{tag.camelize} < Tag
      builder_method #{builder_method.inspect}
      tag #{tag.inspect}

      #{self_closing_method}
    end
  RUBY
end