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



1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
# File 'lib/forme.rb', line 1242

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