Lighthouse has a new layout. Prefer the old one? Return to the old layout, and switch back any time from the link at the top of each page.

This project is archived and is in readonly mode.

Helper for HTML5 time tag

#5919

Since other html 5 related helpers are being added as well I thought it'd be nice to also have a convenient helper method for generating a time tag, that automatically deals with setting the datetime attiribute and optionally the contents.

The patch below makes this possible:

time_tag Date.today  # =>
  <time datetime="2010-11-04">November 04, 2010</time>
time_tag Time.now  # =>
  <time datetime="2010-11-04T17:55:45+01:00">November 04, 2010 17:55</time>
time_tag Date.yesterday, 'Yesterday'  # =>
  <time datetime="2010-11-03">Yesterday</time>
time_tag Date.today, :pubdate => true  # =>
  <time datetime="2010-11-04" pubdate="pubdate">November 04, 2010</time>

Reported by s-andringa · November 4th, 2010 @ 06:32 PM

State: resolved
Milestone: none
Assigned to: nobody
Importance: Low

Activity

  1. s-andringa
  2. s-andringa
    s-andringa
    • Tag changed from date, helper, html5, tag, time to date, helper, html5, patch, tag, time

    November 5th, 2010 @ 07:58 AM

  3. Ches Martin
    Ches Martin

    I think it'd be really nice if this took an option parameter for the I18n format.

    December 11th, 2010 @ 08:16 PM

  4. Repository
    Repository
    • State changed from new to resolved

    February 13th, 2011 @ 12:24 AM

  5. Josh Kalderimis
    Josh Kalderimis
    • Importance changed from to Low

    Hi Sjoerd,

    Thanks for the patch, I added a small enhancement to allow for the format to be set via an options argument.

    Keep up the great patching!

    Josh

    February 13th, 2011 @ 12:27 AM