README.md in rails-timeago-2.18.0 vs README.md in rails-timeago-2.19.0

- old
+ new

@@ -1,10 +1,9 @@ # rails-timeago -[![Gem Version](https://badge.fury.io/rb/rails-timeago.svg)](http://badge.fury.io/rb/rails-timeago) -[![Build Status](https://travis-ci.org/jgraichen/rails-timeago.svg?branch=master)](https://travis-ci.org/jgraichen/rails-timeago) -[![Code Climate](https://codeclimate.com/github/jgraichen/rails-timeago.svg)](https://codeclimate.com/github/jgraichen/rails-timeago) +[![Gem Version](https://img.shields.io/gem/v/rails-timeago?logo=ruby)](https://rubygems.org/gems/rails-timeago) +[![Build Status](https://img.shields.io/travis/jgraichen/rails-timeago/master?logo=travis)](https://travis-ci.org/jgraichen/rails-timeago) **rails-timeago** provides a timeago_tag helper to create time tags usable for [jQuery Timeago](https://github.com/rmm5t/jquery-timeago) plugin. ## Installation @@ -31,25 +30,27 @@ Use the following to also include all available locale files: //= require rails-timeago-all +If using a recent Rails with `rails-ujs`, jQuery might not be present anymore. You need to add `jquery-rails` to your `Gemfile` and load it, e.g.: + + //= require jquery + //= require rails-timeago + //= require rails-timeago-all + ## Usage Use the timeago_tag helper like any other regular tag helper: ```erb -<%= timeago_tag Time.zone.now, :nojs => true, :limit => 10.days.ago %> +<%= timeago_tag Time.zone.now limit: 10.days.ago %> ``` ### Available options: -**nojs** -Add time ago in words as time tag content instead of absolute time. -(default: `false`) - **date_only** Only print date as tag content instead of full time. (default: `true`) **format** @@ -68,27 +69,27 @@ String that will be returned if time is `nil`. (default: `'-'`) **title** A string or block that will be used to create a title attribute for timeago tags. It set to nil or false no title attribute will be set. -(default: `proc { |time, options| I18n.l time, :format => options[:format] }`) +(default: `proc { |time, options| I18n.l time, format: options[:format] }`) All other options will be given as options to the time tag helper. The above options can be assigned globally as defaults using ```ruby -Rails::Timeago.default_options :limit => proc { 20.days.ago }, :nojs => true +Rails::Timeago.default_options limit: proc { 20.days.ago } ``` A global limit should always be given as a block that will be evaluated each time the rails `timeago_tag` helper is called. That avoids the limit becoming smaller the longer the application runs. ## I18n **rails-timeago 2** ships with a modified version of jQuery timeago that allows to include all locale files at once and set the locale via an option or per element via the `lang` attribute: ```erb -<%= timeago_tag Time.zone.now, :lang => :de %> +<%= timeago_tag Time.zone.now, lang: :de %> ``` The following snippet will print a script tag that set the jQuery timeago locale according to your `I18n.locale`: ```erb @@ -109,11 +110,9 @@ ``` *Note:* English is included in jQuery timeago library, but can be easily override by include an own file that defines `jQuery.timeago.settings.strings["en"]`. See a locale file for more details. **rails-timeago** includes locale files for the following locales taken from [jQuery Timeago](https://github.com/rmm5t/jquery-timeago). - -> de cy pl mk zh-CN bs en-short it fi es uk lt zh-TW sk hy ca pt el sv ar no fa fr pt-br tr he bg ko uz cz sl hu id hr ru nl fr-short da ja ro th Your customized jQuery locale files must be changed to work with **rails-timeago 2**. Instead of defining your locale strings as `jQuery.timeago.settings.strings` you need to define them like this: ```js jQuery.timeago.settings.strings["en"] = {