Class: Forme::Serializer::AmericanTime

Inherits:
Forme::Serializer show all
Defined in:
lib/forme.rb

Overview

Overrides formatting of dates and times to use an American format without timezones.

Constant Summary

Constants inherited from Forme::Serializer

ESCAPE_HTML, ESCAPE_HTML_PATTERN, SELF_CLOSING

Instance Method Summary collapse

Methods inherited from Forme::Serializer

#serialize_close, #serialize_open

Instance Method Details

#call(tag) ⇒ Object



1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
# File 'lib/forme.rb', line 1347

def call(tag)
  case tag
  when Tag
    if tag.type.to_s == 'input' && %w'date datetime'.include?((tag.attr[:type] || tag.attr['type']).to_s)
      attr = tag.attr.dup
      attr.delete(:type)
      attr.delete('type')
      attr['type'] = 'text'
      "<#{tag.type}#{attr_html(attr)}/>"
    else
      super
    end
  else
    super
  end
end