Class: Mullet::HTML::Attributes

Inherits:
Hash
  • Object
show all
Defined in:
lib/mullet/html/attributes.rb

Overview

Maps attribute names to values. Also renders attributes to HTML.

Instance Method Summary collapse

Instance Method Details

#escape_quote(value) ⇒ Object



6
7
8
# File 'lib/mullet/html/attributes.rb', line 6

def escape_quote(value)
  return value.include?('"') ? value.gsub(/"/, '"') : value
end

#renderObject

Renders attributes to HTML syntax.

Returns:

  • rendered HTML



13
14
15
16
17
18
19
# File 'lib/mullet/html/attributes.rb', line 13

def render()
  output = ''
  each do |key, value|
    output << %( #{key}="#{escape_quote(value)}")
  end
  return output
end