Class: Markaby::HTML5

Inherits:
Tagset
  • Object
show all
Defined in:
lib/markaby/lib/markaby/html5.rb

Constant Summary collapse

AttrsHTML5 =
[:contenteditable, :contextmentu, :draggable, :dropzone,
:hidden, :role, :spellcheck, :translate]

Class Method Summary collapse

Methods inherited from Tagset

transform_attribute_hash, transform_attribute_name, transform_attributes, valid_attribute_name?, validate_and_transform_attributes!

Class Method Details

.can_handle?(tag_name) ⇒ Boolean

Returns:

  • (Boolean)


17
18
19
# File 'lib/markaby/lib/markaby/html5.rb', line 17

def can_handle? tag_name
  custom_element? tag_name
end

.custom_element?(tag_name) ⇒ Boolean

Returns:

  • (Boolean)


13
14
15
# File 'lib/markaby/lib/markaby/html5.rb', line 13

def custom_element? tag_name
  tag_name.to_s.include? "_"
end

.custom_element_tag_for(tag_name) ⇒ Object



29
30
31
# File 'lib/markaby/lib/markaby/html5.rb', line 29

def custom_element_tag_for tag_name
  tag_name.to_s.tr("_", "-").to_sym
end

.default_optionsObject



5
6
7
8
9
10
11
# File 'lib/markaby/lib/markaby/html5.rb', line 5

def default_options
  super.merge({
    output_xml_instruction: false,
    output_meta_tag: "html5",
    root_attributes: {}
  })
end

.handle_tag(tag_name, builder, *args, &block) ⇒ Object



21
22
23
# File 'lib/markaby/lib/markaby/html5.rb', line 21

def handle_tag tag_name, builder, *args, &block
  builder.tag! tag_name, *args, &block
end

.validate_and_transform_tag_name!(tag_name) ⇒ Object



25
26
27
# File 'lib/markaby/lib/markaby/html5.rb', line 25

def validate_and_transform_tag_name! tag_name
  custom_element?(tag_name) ? custom_element_tag_for(tag_name) : super
end

.validate_attribute!(tag_name, attribute_name) ⇒ Object



33
34
35
# File 'lib/markaby/lib/markaby/html5.rb', line 33

def validate_attribute! tag_name, attribute_name
  custom_element?(tag_name) || super
end