Module: Plutonium::Helpers::ContentHelper

Defined in:
lib/plutonium/helpers/content_helper.rb

Instance Method Summary collapse

Instance Method Details

#timeago(date, format: :long) ⇒ Object



4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/plutonium/helpers/content_helper.rb', line 4

def timeago(date, format: :long)
  return if date.blank?

  content = I18n.l(date, format:)
  tag.time(
    content,
    title: content,
    data: {
      controller: "timeago",
      timeago_refresh_interval_value: 1000,
      timeago_include_seconds_value: true,
      timeago_add_suffix_value: true,
      timeago_datetime_value: date.iso8601
    }
  )
end