diff options
author | Antonio Tapiador del Dujo <atapiador@dit.upm.es> | 2012-03-18 11:58:08 +0100 |
---|---|---|
committer | Antonio Tapiador del Dujo <atapiador@dit.upm.es> | 2012-03-18 12:07:51 +0100 |
commit | 05406442b81be49154737d763fc65c7fb0f03608 (patch) | |
tree | 19e1b66bb872556c7267a6101cfe1de7f3d70722 /actionpack/lib/action_view/helpers | |
parent | 2b5cb1cd41ea765ae665321236c83c9d0128636b (diff) | |
download | rails-05406442b81be49154737d763fc65c7fb0f03608.tar.gz rails-05406442b81be49154737d763fc65c7fb0f03608.tar.bz2 rails-05406442b81be49154737d763fc65c7fb0f03608.zip |
time_tag support for blocks
Diffstat (limited to 'actionpack/lib/action_view/helpers')
-rw-r--r-- | actionpack/lib/action_view/helpers/date_helper.rb | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/actionpack/lib/action_view/helpers/date_helper.rb b/actionpack/lib/action_view/helpers/date_helper.rb index 2d37923825..ee9f0da9b8 100644 --- a/actionpack/lib/action_view/helpers/date_helper.rb +++ b/actionpack/lib/action_view/helpers/date_helper.rb @@ -625,13 +625,18 @@ module ActionView # time_tag Date.today, :pubdate => true # => # <time datetime="2010-11-04" pubdate="pubdate">November 04, 2010</time> # - def time_tag(date_or_time, *args) + # <%= time_tag Time.now do %> + # <span>Right now</span> + # <% end %> + # # => <time datetime="2010-11-04T17:55:45+01:00"><span>Right now</span></time> + # + def time_tag(date_or_time, *args, &block) options = args.extract_options! format = options.delete(:format) || :long content = args.first || I18n.l(date_or_time, :format => format) datetime = date_or_time.acts_like?(:time) ? date_or_time.xmlschema : date_or_time.rfc3339 - content_tag(:time, content, options.reverse_merge(:datetime => datetime)) + content_tag(:time, content, options.reverse_merge(:datetime => datetime), &block) end end |